Method overloading with ref and out
In this chapter you will learn:
ref and out modifiers and method overloading
ref and out modifiers are part of the method signature.
class Math//j av a 2 s.c o m
{
int add(int i, int j)
{
return i + j;
}
int add(ref int i, ref int j){
return i + j;
}
}
ref and out cannot coexist
The following code shows that ref and out cannot coexist.
class Math//from jav a 2 s . c o m
{
int add(out int i, out int j)
{
return i + j;
}
int add(ref int i, ref int j){
return i + j;
}
}
Compile time error:
Next chapter...
What you will learn in the next chapter:
Home » C# Tutorial » Class