Writing .NET Classes

  • Thread starter Thread starter Jen
  • Start date Start date
J

Jen

I am fairly new to .NET and was wondering if someone
could point me to a tutorial/overview of writing custom
classes? Thank you.
 
Here's a custom class:

public class foo
{
public foo()
{
}
}

What else do you need to know?

--
HTH,

Kevin Spencer
Microsoft MVP
..Net Developer
Neither a follower nor a lender be.
 
Well, I guess a little more background than that. Why
would you choose to use them? How they are integrated?
Differences between modules? etc...
 
Jen,
Modules in VB.Net are just a nice/simple way to do something else: create a
utility class. When you do:

Module Foo
public function DoSomething() as string
...
end function
end Module

it actually gets compiled as a class:

CLASS Foo
PRIVATE SUB NEW
END SUB

public SHARED function DoSomething() as string
...
end function
end CLASS

I've capitalized the difference between the two. It might even mark the
class as NotInheritable (I'm not sure, though it should), but that's really
beyond the point. What I'm trying to say is that a module is a
class...atleast a static/shared class. If you prefer to use one syntax over
another, I see little harm in that (though it might confuse C#/Java
programmers). The difference between the type of class a Module creates (a
static/shared class) and a normal "instance" class is that you never create
an instance of a module.

You would never do:

Dim myFoo as Foo = new Foo()

actually, you can't do this....you would only use it for utility purposes:

dim someValue as string = Foo.DoSomething()

whereas a normal class you create an instance:

dim user as User = new User()
user.UserId = 1
user.UserName = "asdas"
.....


Karl
 
Why
would you choose to use them?

Everything in .Net is an object (class). So, you would use them when you
need a class that doesn't exist in the CLR.
How they are integrated?

I'm not sure what you mean by that. Integrated with what?
Differences between modules?

Karl covered that in his reply.

You might benefit from the .Net SDK, which is a free download:

http://www.microsoft.com/downloads/...A6-3647-4070-9F41-A333C6B9181D&displaylang=en

It has lots of articles, tutorials, and sample code in it, as well as a
complete reference to the CLR.
--
HTH,

Kevin Spencer
Microsoft MVP
..Net Developer
Neither a follower nor a lender be.
 
Back
Top