using System;
/// <summary>
/// A simple indexer example.
/// </summary>
class ConsolePrint
{
class User {
private string FirstName = "王";
private string LastName = "小名";
public User() { }
public string FullName
{
get
{
return this.FirstName + this.LastName;
}
set { }
}
}
static void Main(string[] args)
{
var user = new User();
Console.WriteLine("Username = {0}" , user.FullName );
Console.ReadLine();
}
}
/// <summary>
/// A simple indexer example.
/// </summary>
class ConsolePrint
{
class User {
private string FirstName = "王";
private string LastName = "小名";
public User() { }
public string FullName
{
get
{
return this.FirstName + this.LastName;
}
set { }
}
}
static void Main(string[] args)
{
var user = new User();
Console.WriteLine("Username = {0}" , user.FullName );
Console.ReadLine();
}
}
結果: 可以當set get函式使用 , 方便封裝
沒有留言:
張貼留言