2 Replies - 827 Views - Last Post: 08 January 2010 - 05:40 PM Rate Topic: -----

#1 zukeru   User is offline

  • D.I.C Head

Reputation: 2
  • View blog
  • Posts: 163
  • Joined: 25-December 09

Help Convert C# to VB.net

Posted 07 January 2010 - 02:53 PM

Can someone help me convert this ?


using System;

delegate bool CompareOp(object lhs, object rhs);

class MainEntryPoint {
	static void Main() {
		Employee[] employees = {
			  new Employee("B", 20000),
			  new Employee("E", 10000),
			  new Employee("D", 25000),
			  new Employee("W", (decimal)1000000.38),
			  new Employee("F", 23000),
			  new Employee("R'", 50000)};
		CompareOp employeeCompareOp = new CompareOp(Employee.RhsIsGreater);
		BubbleSorter.Sort(employees, employeeCompareOp);

		for (int i = 0; i < employees.Length; i++)
			Console.WriteLine(employees[i].ToString());
		Console.ReadLine();
	}
}

class Employee{
	private string name;
	private decimal salary;

	public Employee(string name, decimal salary) {
		this.name = name;
		this.salary = salary;
	}

	public override string ToString() {
		return string.Format(name + ", {0:C}", salary);
	}

	public static bool RhsIsGreater(object lhs, object rhs) {
		Employee empLhs = (Employee)lhs;
		Employee empRhs = (Employee)rhs;
		return (empRhs.salary > empLhs.salary) ? true : false;
	}
}

class BubbleSorter {
	static public void Sort(object[] sortArray, CompareOp gtMethod) {
		for (int i = 0; i < sortArray.Length; i++) {
			for (int j = i + 1; j < sortArray.Length; j++) {
				if (gtMethod(sortArray[j], sortArray[i])) {
					object temp = sortArray[i];
					sortArray[i] = sortArray[j];
					sortArray[j] = temp;
				}
			}
		}
	}
}


Is This A Good Question/Topic? 0
  • +

Replies To: Help Convert C# to VB.net

#2 scalt   User is offline

  • D.I.C Regular
  • member icon

Reputation: 63
  • View blog
  • Posts: 344
  • Joined: 22-November 07

Re: Help Convert C# to VB.net

Posted 07 January 2010 - 03:21 PM

http://www.developer...t/csharp-to-vb/

Real nice online tool, just copy/paste your code in and press the button. You don't even need to download anything
Was This Post Helpful? 0
  • +
  • -

#3 Jack Eagles1   User is offline

  • Pugnacious Penguin (inspired by no2pencil)
  • member icon

Reputation: 187
  • View blog
  • Posts: 1,152
  • Joined: 10-December 08

Re: Help Convert C# to VB.net

Posted 08 January 2010 - 05:40 PM

View Postscalt, on 7 Jan, 2010 - 02:21 PM, said:

http://www.developer...t/csharp-to-vb/

Real nice online tool, just copy/paste your code in and press the button. You don't even need to download anything


No fair! I was gonna say that! lol
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1