This code is a java code. Can you please help me convert this to c#?
private static URL URLObj;
private static URLConnection connect;
static String source = "";
public static void main(String[] args) {
try {
URLObj = new URL("http://students.usls.edu.ph");
connect = URLObj.openConnection();
connect.setDoOutput(true);
}
catch (MalformedURLException ex) {
System.out.println("The URL specified was unable to be parsed or uses an invalid protocol. Please try again.");
System.exit(1);
}
catch (Exception ex) {
System.out.println("An exception occurred. " + ex.getMessage());
System.exit(1);
}
try {
BufferedWriter writer = new BufferedWriter(new OutputStreamWriter(connect.getOutputStream()));
writer.write("username=0920307&password=85181395&submit=Login");
writer.close();
BufferedReader reader = new BufferedReader(new InputStreamReader(connect.getInputStream()));
}
}