#968 – Reading a Value from a Variable
November 6, 2013 Leave a comment
Once you’ve assigned a value to a variable, you can read the value back. You can use the variable name anywhere that a value of the appropriate type is expected.
// Assign value to int variable int n = 5; // Read value from variable n and use it in an expression int result1 = n * 2; string info = string.Format("n={0}, result1={1}", n.ToString(), result1.ToString()); Console.WriteLine(info);