|
INTERVIEW QUESTIONS
MICROSOFT
C#
DETAILS
Question: How do I declare inout arguments in C#?
Answer: The equivalent of inout in C# is ref. , as shown in the following example: public void MyMethod (ref String str1, out String str2) { ... } When calling the method, it would be called like this: String s1; String s2; s1 = "Hello"; MyMethod(ref s1, out s2); Console.WriteLine(s1); Console.WriteLine(s2); Notice that you need to specify ref when declaring the function and calling it.
|
|
|
Category |
C# Interview Questions & Answers -
Exam Mode /
Learning Mode
|
Rating |
(0.2) By 9464 users |
Added on |
10/24/2009 |
Views |
77681 |
Rate it! |
|
|
Question:
How do I declare inout arguments in C#?
Answer:
The equivalent of inout in C# is ref. , as shown in the following example: public void MyMethod (ref String str1, out String str2) { ... } When calling the method, it would be called like this: String s1; String s2; s1 = "Hello"; MyMethod(ref s1, out s2); Console.WriteLine(s1); Console.WriteLine(s2); Notice that you need to specify ref when declaring the function and calling it. Source: CoolInterview.com
If you have the better answer, then send it to us. We will display your answer after the approval.
Rules to Post Answers in CoolInterview.com:-
- There should not be any Spelling Mistakes.
- There should not be any Gramatical Errors.
- Answers must not contain any bad words.
- Answers should not be the repeat of same answer, already approved.
- Answer should be complete in itself.
|
|
Related Questions |
View Answer |
|
How do destructors and garbage collection work in C#?
|
View Answer
|
|
How do I port "synchronized" functions from Visual J++ to C#?
|
View Answer
|
|
Does C# support properties of array types?
|
View Answer
|
|
Is there a way of specifying which block or loop to break out of when working with nested loops?
|
View Answer
|
|
How do I get deterministic finalization in C#?
|
View Answer
|
|
How do I convert a string to an int in C#?
|
View Answer
|
|
Is there an equivalent of exit() for quitting a C# .NET application?
|
View Answer
|
|
How does one compare strings in C#?
|
View Answer
|
|
What is the difference between a struct and a class in C#?
|
View Answer
|
|
How can I get the ASCII code for a character in C#?
|
View Answer
|
|
Is it possible to inline assembly or IL in C# code?
|
View Answer
|
|
If I return out of a try/finally in C#, does the code in the finally-clause run?
|
View Answer
|
|
Does C# support try-catch-finally blocks?
|
View Answer
|
|
Is it possible to have a static indexer in C#?
|
View Answer
|
|
What optimizations does the C# compiler perform when you use the /optimize+ compiler option?
|
View Answer
|
|
How can I access the registry from C# code?
|
View Answer
|
|
Does C# support #define for defining global constants?
|
View Answer
|
|
Is there any sample C# code for simple threading?
|
View Answer
|
|
Is there regular expression (regex) support available to C# developers?
|
View Answer
|
|
Why do I get a security exception when I try to run my C# app?
|
View Answer
|