整几个题给大家玩玩,看看“下盘功夫”怎样
不用编译器,回复你的答案。
感觉现在很多程序员老在追遂各种各样的新名词、新术语,别人把几个英语单词整一块,取出第一个字母,X除外,这年头,X牛啊,不在第一也优先取它,然后好像记住了这些缩写的意思,就是一个不会落伍的程序员,有些该学,理解思想是根,至于记不记得住那缩写,无关紧要吧,咱要做的是在自己的层面上有自己的新术语创立出来,让别人去记,大家说是不。举个例子吧,听棠.net就整一个什么什么(我对人名,地名,术语名这些记忆不敏感,上街要是跟人走,从不记路)出来(数据访问方面的),好东西来的,然后也出个缩写,这些东西的话,理解人家思路,拓展自家思路是本,看了人家的想法,自己在实战中就要运用人家的思想,用人家的东西还是自己再写,再扩展看实际情况。
反过来,有些基础的东西还是要记住,要清楚的,言归正传。
1.
interface IGrandFather
{
void F();
}
class Father:IGrandFather
{
public void F()
{
Console.WriteLine("\nFather.");
}
}
class Children:Father
{
public new void F()
{
Console.WriteLine("\nChildren.");
}
}
class Test
{
public static void Main(string[] args)
{
IGrandFather gf = new Children();
gf.F();
}
}
{
void F();
}
class Father:IGrandFather
{
public void F()
{
Console.WriteLine("\nFather.");
}
}
class Children:Father
{
public new void F()
{
Console.WriteLine("\nChildren.");
}
}
class Test
{
public static void Main(string[] args)
{
IGrandFather gf = new Children();
gf.F();
}
}
2.
interface IGrandFather
{
void F();
}
class Father:IGrandFather
{
public virtual void F()
{
Console.WriteLine("\nFather.");
}
}
class Children:Father
{
public override void F()
{
Console.WriteLine("\nChildren.");
}
}
class Test
{
public static void Main(string[] args)
{
IGrandFather gf = new Children();
gf.F();
}
}
3.
interface IGrandFather
{
void F();
}
class Father:IGrandFather
{
public virtual void F()
{
Console.WriteLine("\nFather.");
}
}
class Children:Father
{
public void F(string arg)
{
Console.WriteLine("\nChildren:{0}",arg);
}
}
class Test
{
public static void Main(string[] args)
{
IGrandFather gf = new Children();
gf.F();
}
}
4.
interface IGrandFather
{
void F();
}
abstract class Father:IGrandFather
{
public void F()
{
Console.WriteLine("\nFather.");
}
}
class Children:Father
{
public void F()
{
Console.WriteLine("\nChildren.");
}
}
class Test
{
public static void Main(string[] args)
{
IGrandFather gf = new Children();
gf.F();
}
}
5.
interface IGrandFather
{
void F();
}
abstract class Father:IGrandFather
{
public virtual void F()
{
Console.WriteLine("\nFather.");
}
}
class Children:Father
{
public void F()
{
Console.WriteLine("\nChildren:{0}");
}
}
class Test
{
public static void Main(string[] args)
{
IGrandFather gf = new Children();
gf.F();
Console.ReadLine();
}
}
6.
interface GrandFather
{
void F();
}
class Father:GrandFather
{
public void F()
{
Console.WriteLine("\nFather.");
}
}
class Children:Father,GrandFather
{
public new void F()
{
Console.WriteLine("\nChildren");
}
}
class Test
{
public static void Main(string[] args)
{
GrandFather gf = new Children();
gf.F();
Console.ReadLine();
}
}
7.readonly和const 最本质的区别在哪?
8.编写类型转换时,是别的类型转为自身用隐式转换,还是反之用隐式?
9.这段代码呢?
using System;
class A
{
public virtual void F(string p)
{
Console.WriteLine(p);
}
}
class B:A
{
public void F(ref string p)
{
Console.WriteLine("ref:"+p);
}
}
class Test
{
public static void Main(string[] args)
{
string s = "xxxx";
B b = new B();
b.F(s);
b.F(ref s);
}
}
class A
{
public virtual void F(string p)
{
Console.WriteLine(p);
}
}
class B:A
{
public void F(ref string p)
{
Console.WriteLine("ref:"+p);
}
}
class Test
{
public static void Main(string[] args)
{
string s = "xxxx";
B b = new B();
b.F(s);
b.F(ref s);
}
}