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()));
        }
    }

No one is going to just give you the code for it, without any effort on your part. Java and C# are very similar so you should have a rough template to understand what is going on. You should try and write some C# code attempting to mymic the functionality and ask questions on that.

The code here is creating a new connection to the specified url and is sending a username and password to it. Then it prepares a reader to look at the response (I assume to check if you are successfully logged in or not)

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.