473,324 Members | 2,002 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,324 software developers and data experts.

beginner c# question

I'm coming from the java world, so I'm sorry if this is a simplistic
question. I've read enough to be dangerous :< and would like a quick
overview.

In java, everything with implemenation is implemented as a class. In C#
there are not only classes but structs, enumerations. I know one is on the
heap (classes?) and one's on the stack (structs?), but more than that, why
are they broken out? It just seems to be a bit over complicated for
something I don't quite see the benefits of? Any gentle nudges in the right
direction would be appreciated. Thanks.
Nov 16 '05 #1
3 1236
Structs exist for perfomance reasons, they are like light classes and
because they are in the stack they don't have to wait to be collected by the
GC
Regards,
Daniel Carbajal
MVP

"Flip" <[remove]ph******@hotmail.com> wrote in message
news:eD**************@TK2MSFTNGP14.phx.gbl...
I'm coming from the java world, so I'm sorry if this is a simplistic
question. I've read enough to be dangerous :< and would like a quick
overview.

In java, everything with implemenation is implemented as a class. In C#
there are not only classes but structs, enumerations. I know one is on the heap (classes?) and one's on the stack (structs?), but more than that, why
are they broken out? It just seems to be a bit over complicated for
something I don't quite see the benefits of? Any gentle nudges in the right direction would be appreciated. Thanks.

Nov 16 '05 #2
Hi,
you would have to check out the difference between reference types and value
types. say you have 2 integers a and b.
doing a = b would copy the value of b into a. say you have 2 objects a and b
doing a = b would not create a new object but makes both a and b point to
the same object. you can modify the object using either a or b. so now the
object is referenced by 2 variables. when this count drops to zero garbage
collection takes place(not right after it drops to zero, it may take some
time to do the garbage collecgtion). structures are value types. classes are
reference types. this is a starting point. you will have tro read futher in
some good c# book.
regards.
Lingesh

"Daniel" wrote:
Structs exist for perfomance reasons, they are like light classes and
because they are in the stack they don't have to wait to be collected by the
GC
Regards,
Daniel Carbajal
MVP

"Flip" <[remove]ph******@hotmail.com> wrote in message
news:eD**************@TK2MSFTNGP14.phx.gbl...
I'm coming from the java world, so I'm sorry if this is a simplistic
question. I've read enough to be dangerous :< and would like a quick
overview.

In java, everything with implemenation is implemented as a class. In C#
there are not only classes but structs, enumerations. I know one is on

the
heap (classes?) and one's on the stack (structs?), but more than that, why
are they broken out? It just seems to be a bit over complicated for
something I don't quite see the benefits of? Any gentle nudges in the

right
direction would be appreciated. Thanks.


This posting is provided "AS IS" with no warranties, and confers no rights
Nov 16 '05 #3
> Flip, in most projects, you won't have to worry too much on where a
variable
is allocated - unless you are in a project the requires extreame
performance.

Thank you for the clarification. I was reading a bit more about it last
night as well, and the article said I won't need it in regular (beginner :>)
programs, but maybe when I start interfacing with some Win APIs I might need
it there.

Thanks again for the clarification! :>
Nov 16 '05 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

11
by: Svens | last post by:
Hey everyone! I'm a math student working on a short script involving logs. I have a function on my scientific calculator, and was wondering if there was a similar funtion in python. For example:...
3
by: jvax | last post by:
Hi all, I hope I'm posting in the right NG... I have a data text file I want to read from a c++ program. the data file goes like this: 90 # number of balls 33 42 13
1
by: Mike Malter | last post by:
I am just starting to work with reflection and I want to create a log that saves relevant information if a method call fails so I can call that method again later using reflection. I am...
14
by: z_learning_tester | last post by:
But I can't seem to find the answer. The question is how do you reverse the words in a string? Or how do you reverse the numbers listed in a string? The example is usually something like: Turn...
12
by: Blaze | last post by:
I am doing the first walk through on the Visual Studio .Net walkthrough book to learn a little about programming. I am having issues with the first tutorial not running correctly. It seems that...
5
by: optimistx | last post by:
As a beginner in javascript I had a question. I was reading FAQ and posts here. I became very unhappy: Obviously this group is mainly for wise, pedantic, unkind etc people, who already know...
10
by: Roman Zeilinger | last post by:
Hi I have a beginner question concerning fscanf. First I had a text file which just contained some hex numbers: 0C100012 0C100012 ....
4
by: a | last post by:
Dear all vb.net developer I want to know the time I need to master vb.net? I'm beginner
3
by: Ben Keshet | last post by:
I have a probably simple beginner's question - I have a script that I am currently able to print its output. instead, i want to write it into a file - I tried different versions of write() but...
2
by: roanhn | last post by:
Hello. I've to to write a master's thesis. Currently I deal with php, mysql, ajax. Fate decreed that I've to choose one of this subjects: 1.gdi+ library in .net technology 2.ado.net technology...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.