using System;
using System.Collections.Generic;
using System.Text;namespace ConsoleApplication14
{
public class S
{
private string s;
public string N
{
get
{
return this.s;
}
set
{
this.N = value;
}
}
public S(string s2)
{ this.N = s2;
}
}
class Program
{
static void Main(string[] args)
{
S z = new S("ZHANG");
Console.WriteLine(z.N);
}
}
}
using System.Collections.Generic;
using System.Text;namespace ConsoleApplication14
{
public class S
{
private string s;
public string N
{
get
{
return this.s;
}
set
{
this.N = value;
}
}
public S(string s2)
{ this.N = s2;
}
}
class Program
{
static void Main(string[] args)
{
S z = new S("ZHANG");
Console.WriteLine(z.N);
}
}
}
using System.Collections.Generic;
using System.Linq;
using System.Text;namespace ConsoleApplication2
{
using System;
using System.Collections.Generic;
using System.Text; namespace ConsoleApplication14
{
public class S
{
private string s; public string S1
{
get { return s; }
set { s = value; }
}
public S(string s2)
{ S1 = s2;
}
}
class Program
{
static void Main(string[] args)
{
S z = new S("ZHANG");
Console.WriteLine(z.S1);
}
}
}
}
{
get
{
return this.s;
}
set
{
this.N = value;
}
}
在设置N时(给N赋值时),会造成无限递归。
{
this.N = value;
} set
{
this.s = value;
}