Can I assign either integer or char value to a variable?
can i assign either integer or char value to a variable in c # if yes then how or which type of variable
Know the answer? Post it — somebody with the same question will find it here.
Sign in to answer this question
It is the same account you read, post and publish with — and you will come straight back to this page.
VulpesPosted Mar 8, 2013, 6:13 AM
ta muPosted Mar 8, 2013, 3:36 AM
{
dynamic value;
if (textBox1.Text == textBox2.Text)
{ textBox2.Text = value; }
}
i write this code but there is red line under value in 2nd last line
and error is
one or more types required to compile a dynamic variable connot be found. are u mising the refrence to microsoft.cshap.dll and system.core
i try to find these refencees but could no may b this is due to because i am using .net2 frame work or there is other problem
Vishal GilbilePosted Mar 8, 2013, 3:15 AM
yes you can assign integer or char value to a variable in any .net framework
For .Net Framework less than 4.0
you can do this by declaring an object variable
for eg:
object value='Y';
or
object value=10;
In case of .net framework 4.0 you are provided with a new special datatype named dynamic, we can make use of it for dynamically assigning character or integer or any other value to the variable. All you need to do is declare a dynamic variable.
dynamic value='Y';
or
dynamic value=10;
Hope that solves your issue.
With Regards,
Vishal Gilbile.