answersLogoWhite

0

The example below shows how to do it in C#.

using System;

namespace Type_check_for_vars

{

class Program

{

static void Main(string[] args)

{

object myVar = null;

myVar = (int) 10;

if (myVar is int)

{

Console.WriteLine("myVar is type of {0} and has value - {1}", myVar.GetType().ToString(), myVar);

}

myVar = (char)'a';

if (myVar is char)

{

Console.WriteLine("myVar is type of {0} and has value - {1}", myVar.GetType().ToString(), myVar);

}

Console.ReadLine();

}

}

}

User Avatar

Wiki User

12y ago

What else can I help you with?

Related Questions

What are data type qualifiers?

In programming languages, a type qualifier indicates the special properties of a variable. Type qualifiers can be used for code optimization and for finding defects. In C/C++ one of the popular type qualifiers is the const qualifire. It is used to fix the value of a variable after the variable is initialized.


How do you type in the sntinal variable symbol in c?

Use the keyboard.


What is syntax in c plus plus for declaring a variable?

type variable {[optional array size]} {= optional initializer};


What is meant by value type and reference type in c?

When you work with passing by value C creates a copy of the variable which is referencing to. Thus, it spends free RAM space just to dublicate the variable which already excists.When you work with passing by reference type C works with address of the variable, what makes using of free RAM space more efficient.


How is a structure type pointer variable declared in c?

struct thisorthat *ptr;


What type of equation has a graph that is horizontal?

It is likely that a horizontal line on a graph will have the equation y=c, where c is a variable.


What is a primitive type variable in c plus plus?

same the types used in C. that is int...char...float...


How a variable is declared and initialized during declaration in c?

During declaration, the declaration goes like this: extern <type> <variable-name> or <type> <function-name> (<parameter list>);


What is 'variable' in C programming?

It's a part of the program's data, which has a name,type and value.


What is meant by value type and reference type in?

When you work with passing by value C creates a copy of the variable which is referencing to. Thus, it spends free RAM space just to dublicate the variable which already excists.When you work with passing by reference type C works with address of the variable, what makes using of free RAM space more efficient.


How do you use define in C?

Just type declare then the variable that you desire to assigned a certain constant value on it. Just type declare then the variable that you desire to assigned a certain constant value on it.


When you divide Polynomials by Monomials can a variable only be divided by the same variable Example Can c-squared only be divided c or can it be divided by x and y and v etc?

X2/X = X ======= I do not think you can divide one variable type by another.