- 求下述代码片段的输出,并且解释原因
static void Main() { var i = 5; UpdateValue(i); Console.WriteLine(i); var s = new Student() { Age = 10 }; UpdateReference(s); Console.WriteLine(s.Age); var rs = new Student() { Age = 10 }; UpdateReference(ref rs); Console.WriteLine(rs.Age); var t = new Student() { Age = 20 }; UpdateProperty(t); Console.WriteLine(t.Age); } static void UpdateValue(int input) { input = 10; } static void UpdateReference(Student t) { t = new Student() { Age = 15 }; } static void UpdateReference(ref Student rt) { rt = new Student() { Age = 15 }; } static void UpdateProperty(Student s) { s.Age = 25; } class Student { public int Age { get; set; } }
- 求下述代码片段的输出,并且解释原因
class Root { public object o1 = new object(); public object o2 => new object(); public object o3() { return new object(); } } void Main() { var a = new Root(); var x = a.o1; var y = a.o1; Console.WriteLine(ReferenceEquals(x, y)); var i = a.o2; var j = a.o2; Console.WriteLine(ReferenceEquals(i, j)); var p = a.o3(); var q = a.o3(); Console.WriteLine(ReferenceEquals(p, q)); }
- Linq的延迟求值是什么?
- 求下述代码片段的输出,并解释原因
var i = 0; var tempList = Enumerable.Range(1, 10000) .Select( item => { i += 1; return item; }) .Where(t => t % 3 == 0) .Take(5); Console.WriteLine(i);
HashSet<T>
与SortedSet<T>
在数据结构上的区别Dictionary<TKey,TValue>
中的TKey和TValue是值还是类型,使用时Dictionary<TKey,TValue>
与Hashtable
有什么区别- 协变和逆变是什么?
- 如何判断变量储存在栈上还是堆上
- 简述CLR垃圾回收策略
- 简述
async Task
,async Task<T>
,async void
方法之间的区别- 相比Thread使用async方法有什么好处
- 什么情况下会用到
async void
? - 如果上述三种异步方法执行过程中有异常产生并抛出,方法外部能不能捕捉到?
- 下述语句中,
RareResource
需要实现什么接口using(var x = new RareResource()) { //Use x do something }
- 简单列举类型推断会失效的情况。
- 查阅资料,以Azure Table Storage为例,简述PartitionKey及RowKey的作用,在设计表时和CRUD时需要注意哪些问题
- 使用csharp完成下面反转整数的方法。提示:越界产生时返回0
public int ReverseInteger(int input) { //Write your code here }
Last active
June 24, 2019 01:41
-
-
Save ShineSmile/65893fe01e78c98404b442b22fd5a7e8 to your computer and use it in GitHub Desktop.
interview questions
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
请不要在这里直接回复
请于https://gist.github.com注册、登陆并提交新的文件,并将其地址通过邮箱回复。
谢谢!