hi im bigginer at c# & i have some simple questions..
1-Console.WriteLine("Result is {0}",div);
for what we use {0} here??
the bult in method Tostring() used for what & when??
hi im bigginer at c# & i have some simple questions..
1-Console.WriteLine("Result is {0}",div);
for what we use {0} here??
the bult in method Tostring() used for what & when??
>for what we use {0} here??
It is called Format parameter. A zero-based integer that indicates which element in a list of objects to format.
Console.WriteLine("Result is {0}",div);
See format parameters.
1. You could see them as "placeholders"
int a = 23;
int b = 34;
Console.WriteLine("Result is {0}, second result is {1}.", a ,b );
will produce:
Result is 23, second result is 34.
2. ToString is a basic method all objects have. Because everything is C# is an object you can even do things like this:
string str = 42.ToString();
This turns the numeric litteral 42 into a string which is then assigned to the sring str. So str is now "42".
Of course you do this mostly like this:
string str = "42";
We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.