Write Chinese code programs under .NET
Zhengzuo
2005-3-9
A year ago, when you use Access database to program, create a data layer code through the vs.Net Data Designer, view the generated code, found that there are many Chinese, the table name and field name in the original database are Chinese, The program is running normally, and the relevant documentation knows that the original vs.net default code is UTF-8. Not long ago, I saw it in a blog, so I simply wrote some Chinese code to play with VS.NET, and the result is like a normal writing program.
A bit weird taste, then put the code out.
Using system;
Namespace zhzuo.consoletest
{
//interface
Public interface will fly
{
Void flight ();
}
// Abstract class
Public Abstract Class Bird: Will Flying
{
// virtual method
Public Virtual Void flight ()
{
Console.writeline ("Bird Flight!");
}
// Abstract attribute
Public Abstract String Name
{
Get;
SET;
}
// Abstract method
Public Abstract String Gets the name of the bird ();
}
// Specific class
Public Class Hawk: Bird
{
PRIVATE STRING Variable 1;
//Constructor
PUBLIC Eagle (String Name)
{
Variable 1 = name;
}
Public Override String Name
{
Get {return variable 1;}
Set {Variable 1 = Value;}
}
// rewrite the basic class method
Public Override Void flight ()
{
Console.writeline ("Eagle is flying!");
}
Public override string Gets the name of the bird ()
{
Return variable 1;
}
}
//interface
Public Interface Airplane: Flying things
{
String type
{
Get;
}
String Get Name ();
}
// Specific class
PUBLIC CLASS fighter: aircraft
{
Public String Type
{
Get {Return "Aircraft Type: Fighter";
}
Public String Get Name ()
{
Return "fighter";
}
Public void flight ()
{
Console.writeLine ("Fighter Flight");
}
}
Public Class Zzconsole
{
[Stathread]
Static void main (string [] args)
{
Birds One bird = New Eagle ("Gray Eagle");
Fighter aircraft = New fighter ();
Console.writeline (a bird. Name); // Gray eagle
A bird. Name = "Black Eagle";
Console.writeline (a bird. Name); // Black Eagle
Console.Writeline (a bird. Get the name of the bird ()); // Black Eagle
Console.writeline (a plane. Type); // aircraft type: fighter
Console.writeline (a plane. Get Name ()); // Fighter
Will flying things flyer = a bird;
Flight. Flight (); // Eagle is flying!
Flyer = a plane;
Flyer. Flight (); // Fighter flight
Console.readline ();
}
}
}