0

what are tjose "{" }" in the codes?

sorry if its a stupid question im new at this :)

2nd Aug 2016, 4:27 PM
Mario Fratellini
Mario Fratellini - avatar
5 Answers
+ 1
the two ways i know to use them (im a beginner also) are: method name { insert code her that u want method to do } or int x = 7; Console.WriteLine("Your number is {0}", x); for the first one it can be for class or namespace also...srry if this is confusing
2nd Aug 2016, 5:24 PM
Dakota Lewis
Dakota Lewis - avatar
+ 1
Those are boundaries. { } curly braces enclose a block of code, to let the compiler know where is the limitation of a certiain block of code.
3rd Aug 2016, 7:41 PM
Erwin Mesias
Erwin Mesias - avatar
0
thanks bro :)
2nd Aug 2016, 5:30 PM
Mario Fratellini
Mario Fratellini - avatar
0
no problemo :)
2nd Aug 2016, 5:40 PM
Dakota Lewis
Dakota Lewis - avatar
0
oh forgot to expand on the second one, think of the {0} as a placeholder for an array or a list...c# starts counting from 0 so that is why u use zero...but if u need more values u use 1,2,3,etc....better to show you: int x = 5; int y = 8; int z = 2; Console.WriteLine("Your numbers are {0},{1}, and {2}", x, y, z); since x is the first one passed when you do the writeline it would take the {0} placeholder, followed by y taking {1} and so on... if u were to pass it like this Console.WriteLine("Your numbers are {0},{1}, and {2}", z, x, y); then z would take the first place holder {0} and so on...hope that helps a little more for that one lol
2nd Aug 2016, 5:50 PM
Dakota Lewis
Dakota Lewis - avatar