newbie questions ^_^!!!!!!!!!!!!11 - Programmers Heaven

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Categories

newbie questions ^_^!!!!!!!!!!!!11

andrestanderandrestander Posts: 1Member
1. After I written in a public class, can I access the methods in my class without having to declare an instance of it?

Like for ex.

public class lol()
{

Public void asdf()
{

}

}

If I do lol.asdf(); from the Form_Load method will it work?


2. When declaring an instance of a class, why do we have to write it in a weird way?

System.IO.StreamReader streamrdr = New StreamReader(filepath)

Why it cant be just

System.IO.StreamReader(filepath) As New streamrdr

3. I was good with Vb 6.0 long time ago, and I think calling windows API with vb 6.0 MUCH easier since there was a little tool that came with vb 6.0 studio that had all of windows API and their functions listed.

Question, is theres anything similar to that in C#?

4. Last question :P
Is theres a certain method or class in C# that allows me to write and retrieve records easily from a file? Because vb 6.0 did that and I was able to write a simple phonebook application that stored the date in a textfile.


I really hope I ever find an answer to my question and thanks in advance =]

Comments

  • karthik_hr123karthik_hr123 Posts: 14Member
    Hi,

    I feel you are a newbie to C# programming/kind of C# syntax. Well, i've got few answers for your questions:
    1.
    Even if you declare a class as public, you can't access its methods/attributes without declaring an instance of it unless you made the attribute/method as 'static'. For instance,
    public class Lol()
    {
    public static void Asdf()
    {

    }
    }

    you can access the method by Lol.Asdf();

    2. well its not a weird way! its very meaningful!
    See:
    System.IO.StreamReader streamrdr = New StreamReader(filepath);
    this declares streamrdr as a variable of the type 'System.IO.StreamReader'; and allocates memory/instantiates it ,by calling its constructor by passing necessary parameter.
    Its just like you declare a variable:
    ;
    then allocating memory for it! Thats all!

    3. I think you are talking about 'Object Browser' window. Visual Studio has an integrated option to see the API docs; accessible via View menu (View -> Object Browser).

    4. I'm not sure about this; as I haven't worked with files much. I this if you remember the class name you used in VB 6, it might be there in C# also. Just find it out in MSDN.

Sign In or Register to comment.