1. start a new C# project,
2. add the 4 class files that you have,
3. run them each through the VB->c# translator you linked to originally,
4. dump the VB logging stuff and add in log4net
5. turn the Windows Scripting stuff from VB into C# (I think your problem with this is that the translator above is flipping out on the types of WindowsScripting Host stuff)
6. Compile and test.
With luck, this will take you a couple of hours. With bad luck, it depends on what the project actually does and that will determine how long.
I wish you good luck.
If you decide to go this route, be liberal about commenting out huge parts of code and compiling and working on eliminating compiling errors first. I'll try to keep an eye out to help you with any other specific questions that I see come across the front page.
Showing posts with label C# 4. Show all posts
Showing posts with label C# 4. Show all posts
Sunday, October 17, 2010
Saturday, October 2, 2010
C# Polymorphism
Compile Time Polymorphism
Method overloading is a great example. You can have two methods with the same name but with different signatures. The compiler will choose the correct version to use at compile time.
Run-Time Polymorphism
Overriding a virtual method from a parent class in a child class is a good example. Another is a class implementing methods from an Interface. This allows you to use the more generic type in code while using the implementation specified by the child. Given the following class definitions:
public class Parent
{
public virtual void SayHello() { Console.WriteLine("Hello World!"); }
}
public class Child : Parent
{
public override void SayHello() { Console.WriteLine("Goodbye World!"); }
}
The following code will output "Goodbye World!":
Parent instance = new Child();
instance.SayHello();
Early Binding
Specifying the type at compile time:
SqlConnection conn = new SqlConnection();
Late Binding
The type is determined at runtime:
object conn = Activator.CreateInstance("System.Data.SqlClient.SqlConnection");
เขียนโดย
abcomp01
ที่
11:07 AM
0
ความคิดเห็น
Email ThisBlogThis!Share to XShare to FacebookShare to Pinterest
ป้ายกำกับ:
C# 4,
Polymorphism
Saturday, August 21, 2010
The dynamic Type
Example Using dynamic
C# 4.0 introduces a new type called dynamic. In some ways it looks just like any other
type such as int, string, or FileStream: you can use it in variable declarations, or func-
tion arguments and return types, as Example 18-4 shows. (The method reads a little
oddly—it’s a static method in the sense that it does not relate to any particular object
instance. But it’s dynamic in the sense that it uses the dynamic type for its parameters
and return value.)
C# 4.0 introduces a new type called dynamic. In some ways it looks just like any other
type such as int, string, or FileStream: you can use it in variable declarations, or func-
tion arguments and return types, as Example 18-4 shows. (The method reads a little
oddly—it’s a static method in the sense that it does not relate to any particular object
instance. But it’s dynamic in the sense that it uses the dynamic type for its parameters
and return value.)
static dynamic AddAnything(dynamic a, dynamic b)
{
dynamic result = a + b;
Console.WriteLine(result);
return result;
}
เขียนโดย
abcomp01
ที่
1:25 AM
0
ความคิดเห็น
Email ThisBlogThis!Share to XShare to FacebookShare to Pinterest
ป้ายกำกับ:
C# 4
Subscribe to:
Posts (Atom)