C#Ó÷ºÐÍ£¬Ê¹³ÌÐò¸üÁé»î£¬Ò²¸üÊ¡ÐÔÄÜ
ÏÈÉùÃ÷£¬ÎÒ²»ÊÇÕâ·½ÃæµÄר¼Ò£¬Ö»ÊǸÉÈí¼þËĸöÔ²»ÖªÌìÓжà¸ßµØÓжàÓ²µÄСº¢×Ó
Ê×ÏÈ£¬ÀàÐÍת»»ÊÇÓÐÒ»¶¨¿ªÏúµÄ
ÎÒÊÔ¹ýÕâÑùµÄ´úÂ룺ÕâÊÇÒ»¸ö¿ØÖÆÌ¨Ó¦ÓóÌÐòµÄProgramÀàµÄ´úÂë
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace ÀàÐÍת»»µÄ¿ªÏú
{
class Program
{
static void Main(string[] args)
{
DateTime now = DateTime.Now;
for (int i = 0; i < 10000000; i++)
{
I a = new A();
((A)a).M();
}
Console.WriteLine(DateTime.Now - now);
now = DateTime.Now;
for (int i = 0; i < 10000000; i++)
{
A a = new A();
a.M();
}
Console.WriteLine(DateTime.Now - now);
}
}
interface I
{
string M();
}
class A : I
{
public string M()
{
return "MA";
}
}
class B : I
{
public string M()
{
return "MB";
}
}
}
ÔËÐеĽá¹ûÊÇÕâÑù£º
00:00:00.3125000
00:00:00.2187500
Çë°´ÈÎÒâ¼ü¼ÌÐø. . .
Ò»ÒڴΣ¬¾ÍÒª¶àÓÃ0.1ÃëÖÓ
ÎҵĻú×ÓÊÇ CPU 2.7GHzË«ºË£¬ 2GÄÚ´æ
ËùÒÔ£¬ÎªÁËÕâôϸСµÄ¶«Î÷£¬ÎÒÆ½Ê±Ð´´úÂ룬Ҳ¾¡Á¿Ê¡µÃ¾ÍÊ¡¡£
·ºÐÍÎÒÓõúܶ࣬²»¹ý¶¼Ã»ÓÐÉîÈëȥѧ¡£²»¹ý×î½üÔÚÑо¿¹ý£¬·ºÐͶ¼¿ÉÒÔʵÀý»¯£¬Õâ¸ø±à³Ì´øÀ´ºÜ´óµÄ·½±ã¡£
ͬÑùÊÔÊÔÏÂÃæµÄ´úÂ룺
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace ÀàÐÍת»»µÄ¿ªÏú
{
class Program
{
static void Main(string[] args)
{
A<B> a = new A<B>();
DateTime now = DateTime.Now;
for (int i = 0; i < 1000000; i++)
{
a.M().M();
}
Console.WriteLine("ÓÃÁË·ºÐ͵Äʱ¼ä£º" + (DateTime.Now - now));
now = DateTime.Now;
for (int i = 0; i < 1000000; i++)
{
Ïà¹ØÎĵµ£º
1 using System;
2 using System.Collections;
3 using System.Configuration;
4 using System.Data;
5 using System.Linq;
6 using System.Web;
7 using System.Web.Security;
8 using&nbs ......
Ò»¡¢Access´ÓExcelÖе¼ÈëÊý¾Ý
1.Óõ½µÄExcel±íµÄ¸ñʽ¼°ÄÚÈÝ
ʵÏÖ
OleDbConnection con = new OleDbConnection();
try
{
OpenFileDialog openFile = new OpenFileDialog();//´ò¿ªÎļþ¶Ô»°¿ò¡£
openFile.Filter = ("Excel Îļþ(*.xls)|*.xls") ......
Ò»£®ÀàÓë½á¹¹µÄʾÀý±È½Ï£º
½á¹¹Ê¾Àý£º
public struct Person
{
string Name;
int height;
int weight
public bool overWeight()
{
//implement something
}
}
ÀàʾÀý£º
public class TestTime
{
int hours;
int minutes;
int seconds;
public void passtime()
{
//implementation ......
c#±à³Ì»ù´¡Ö®¶þ£ºÌØÐÔ ÕâÀïµÄÌØÐÔÇø±ðÓÚÊôÐÔ£¬ËäÈ»msdnÖÐËÆºõ²¢Ã»ÓÐÇø±ð¶þÕß¡£
ÊôÐÔ£ºÊÇÃæÏò¶ÔÏó±à³ÌµÄ»ù±¾¸ÅÄÌṩÁ˶Ô˽ÓÐ×ֶεķÃÎÊ·â×°£¬ÔÚC#ÖÐÒÔgetºÍset·ÃÎÊÆ÷·½·¨ÊµÏֶԿɶÁ¿ÉдÊôÐԵIJÙ×÷£¬ÌṩÁ˰²È«ºÍÁé»îµÄÊý¾Ý·ÃÎÊ·â×°¡£
ÌØÐÔ£º¹«¹²ÓïÑÔÔËÐÐʱÔÊÐíÌí¼ÓÀàËÆ¹Ø¼ü×ÖµÄÃèÊöÉùÃ÷£¬½Ð×öattributes, Ëü¶Ô³ÌÐòÖеÄÔ ......