Prepare for your Next Interview
|
Welcome to the Geeks Talk forums. You are currently viewing our boards as a guest which gives you limited access to view most discussions and access our other features. By joining our free community you will have access to post topics, communicate privately with other members (PM), respond to polls, upload content and access many other special features. Registration is fast, simple and absolutely free so please, join our community today! If you have any problems with the registration process or your account login, please contact contact us. |
This is a discussion on ref and out parametes within the C# forums, part of the Software Development category; what is difference between ref and out parameter?...
|
|||||||
|
|||
|
Re: ref and out parametes
Hi,
If you are passing variable as a Reference parameters, only assigned variables can be passed, it won't allow you to pass unassigned variables. When you are passing as a out parameters you can pass unassigned variables as a parameters to method, values should be assigned in the method itself. For Example Reference parameters public static void Method(ref int a,ref int b) { .......... } public static void Main() { int a=12,b=2; Method(ref a,ref b); } Out parameters public static void Method(out int a,out int b) { a=10; b=90; .... } public static void Main() { int a,b; Method(out a,out b); } |
![]() |
|
| Thread Tools | |
| Display Modes | |
|
|