sup fellows? Lets rock:
4120, 4096, 4104,...?4104Kód: Vybrat vše
(24 | 4096) & (~(1 << 4))
a) nezkompiluje se
b) 1,2
c) , (tedy pouze znak carka)
d) runtime error recpectively Exceptiond)Kód: Vybrat vše
class Plus { public static void AddPlus() { Prg.AddOp("+",1); } } class Divide { public static void AddDivide() { Prg.AddOp("/",2); } } class Prg { static Dictionary<string, int> d=new Dictionary<string, int>(); public static void AddOp(string s, int i) { d.Add(s,i); } static void Main() { Console.WriteLine(string.Format("{0},{1}",d["+"],d["-"])); new Plus(); new Divide(); } }
4B, 8B, 32B, 64B, 2^32, 2^64B, platform dependent? // B = Byte8BKód: Vybrat vše
size of long
cannot be compiled, 32, 25... dunno actually?Kód: Vybrat vše
delegate int F(); ... a very nice code
System.Object, object, decimal, some class, System.Int64decimal, System.Int64Kód: Vybrat vše
value types
What can interface I1 enforce?b), f) ... more?Kód: Vybrat vše
a) operator * b) public method c) private method d) internal method e) interface I2 f) indexer [] g) static property
Write 2 of the main reasons why to use immutable classes:
1) Immutable classes are thread safe
2) They can be used as hash values in hash tables such as Dictionary
http://codebetter.com/blogs/patricksmac ... -them.aspx
Implement enque in priority queue made of doubly-linked list. Make it safe to use in any context (besides thread safe, exceptions).Answer:Kód: Vybrat vše
class Queue<T, P> { _____Node { public Node prev, next; public T item; public P prio; public Node(T i, P p) { item = t; prio = p; } } public void Enqueue(T item, P prio) { Node n = new Node(item, prio); } public T Dequeue() { ... // count on correct implementation } }
Kód: Vybrat vše
class Queue<T, P> where P:IComparable<P> { class Node { public Node prev, next; public T item; public P prio; public Node(T i, P p) { item = t; prio = p; } } Node first = null; public void Enqueue(T item, P prio) { Node n = new Node(item, prio); lock (this) { if (first == null) first = n; else { Node cur = first; Node prev = null; while (cur != null && prio.CompareTo(cur.prio) <= 0) { prev = cur; cur = cur.next; } prev.next = n; if (cur != null) cur.prev = n; } } } public T Dequeue() { ... }
!NO WARRANTY GUARANTEED!