Tuesday, April 06, 2004 1:01 PM
pdbartlett
Questions, questions (and a couple of answers)
There have been a few questions buzzing around in my head of recent weeks. I've managed to answer a couple myself, but the others remain a mystery. Perhaps someone out there can help?
- Can C# static methods be inherited?
- Obviously they cannot be virtual, but I was wondering whether they were inherited. As the code fragment below shows, they are .
- Can null be cast to any type in C#?
- My initial thoughts were that it could be any of: always, never, and if types are compatible. Again a quick bit of example code showed that the correct answer seems to be "always".
- Does wifi (802.11b/g) always need a switch/router?
- Or is there an equivalent to an ethernet "cross-over" cable?
- Does Bluetooth use/support IP?
- Because I was surprised that a Firewire connection in WinXP does. I was expecting something like Direct Cable Connection, but faster.
The last two aren't at all techie, but have also been bothering me of late. I am afraid that I have not yet done "due Google diligence" yet:
- What is "Oliver's Army" in the Elvis Costello song of the same name?
- Who is the "Radio Star" that "Video Killed" in the Buggles song?
The code referred to above is as follows:
// StaticTest.cs
namespace StaticTest
{
class B
{
internal static void DoSomethingSimple()
{
System.Console.WriteLine("2 + 2 = 4");
}
}
class D : B
{
internal static void DoSomethingComplex()
{
System.Console.WriteLine("(-1) ^ 0.5 = i");
}
}
public class EntryPoint
{
public static void Main()
{
B.DoSomethingSimple();
D.DoSomethingComplex();
D.DoSomethingSimple();
}
}
}
// VoidTest.cs
namespace VoidTest
{
class Test
{
internal void DoIt()
{
System.Console.WriteLine("Hello world!");
}
}
public class EntryPoint
{
public static void Main()
{
object o = null;
Test t = (Test)o;
}
}
}
Both of these simple examples compile and run without error, which (I hope!) demonstrates that the answers given above are correct.