public class Thingy
{
public Thingy()
: this ( "Default" , -1)
{
}
public Thingy( string name)
: this (name, -1)
{
}
public Thingy( string name, int whatever)
{
_name = name;
_whatever = whatever;
}
// Other code...
private string _name;
private int _whatever;
}
* This source code was highlighted with Source Code Highlighter .
public class Thingy
{
public Thingy([ Optional , DefaultParameterValue ( "Default" )] string name,
[ Optional , DefaultParameterValue (-1)] int whatever)
{
}
}
* This source code was highlighted with Source Code Highlighter .
public class Thingy2
{
string n;
int i;
public Thingy2( string name = «Default», int whatever = -1)
{
n = name;
i = whatever;
}
}
* This source code was highlighted with Source Code Highlighter .
Source: https://habr.com/ru/post/66331/
All Articles