1.北京掌上通科技有限公司
static string connn = string.Empty;
static void Main(string[] args)
{
for (int i = 0; i < 10; i++)
{
connn = "hello-" + DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
Thread.Sleep(1000 * 5);
Console.WriteLine(connn);
}
}
输出什么:
测试:输出程序当前运行到那里的时间
2.新媒传信
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Data.SqlClient;
using System.Threading;
namespace ConsoleApplication1
{
class Program
{
static void Main(string[] args)
{
new B();
Console.Read();
}
}
public class A
{
public A()
{
Print();
}
public virtual void Print()
{
}
}
public class B: A
{
int x = 1;
int y;
public B()
{
y = -1;
}
public override void Print()
{
Console.WriteLine("x={0},y={1}", x, y);
}
}
}
输出什么:先属性,后构造,先父类构造,后子类构造。
所以: New B(); 那么:x=1;y=0;
整型默认初始化:为0;
3.如何声明一个DateTime null?
DateTime? dt=null; //前面加一个问号就可以了。
4.