Friday, 1 June 2012

How can we make calculator in vb.net

 This is the simple code of calculator:-

Public Class Form2
    Dim total1 As Integer
    Dim total2 As Integer
    Dim sign As String
    Dim opr As String

    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        TextBox1.Text = TextBox1.Text & "0"
    End Sub

Difference between primitive type and non primitive data type in C#

There are two types of data type in C#

primitive data types are the datatypes which are not objects as they are present in c and c++. eg.int,char,float etc.
where as non primitive are the datatypes which are considered as objects eg. String.
This is one of the reason why java is not a purely object oriented lang as the primitive data types are also allowed in java

Thursday, 31 May 2012

practical interview questions of c#



Q. Write a program in C# that take string input, and print its number of characters.

string name = Console.ReadLine();
Console.WriteLine(name.Length);
Console.ReadLine();

Q. Write a program in C Sharp that take a sentense as input, and show the number of "a" used in the sentense.

string name = Console.ReadLine();
int counter = 0;
for (int i = 0; i < name.Length; i++)
{
if (name[i] == 'a')
{
counter++;
}

Saturday, 19 May 2012

Program of palindrome in c#

using System;
using System.Collections.Generic;
using System.Text;

namespace ConsoleApplication11
{
class Program
{
static void Main(string[] args) {
string str=string .Empty ;
Console.WriteLine("Enter a String name");
string s = Console.ReadLine();
int i = s.Length;
//we can get the Length of string by using Length Property

Friday, 18 May 2012

Main difference between web user control & custom control in asp.net

This is from Microsoft's site:
Web user controls
  • Easier to create
  • Limited support for consumers who use a visual design tool
  • A separate copy of the control is required in each application
  • Cannot be added to the Toolbox in Visual Studio
  • Good for static layout

Thursday, 17 May 2012

In C# Reverse String Program

public string reverse(string str)
{

int len=str.length;
Char[] arr=new Char[len];
for(int i=0;i<len;i++)
{
  arr[i]= str[len-1-i];
 }

In C# Reverse program of number

int n = 1234567;
int left = n;
int rev = 0;
while(left>0)
{
  r = left % 10;  
  rev = rev * 10 + r;
  left = left / 10; 
}

Console.WriteLine(rev);