c# ?????????? void main ????

This is a discussion on c# ?????????? void main ???? within the C# Programming forums, part of the General Programming Boards category; I'm working through C# How to Program Deitel. They write main as static void. Based on the C++ standard, is ...

  1. #1
    essence of digital xddxogm3's Avatar
    Join Date
    Sep 2003
    Posts
    589

    c# ?????????? void main ????

    I'm working through C# How to Program Deitel.
    They write main as static void.
    Based on the C++ standard, is this valid?
    Should I not be returning an int to adhear to the os requirement of successful completion of the program??
    "Hence to fight and conquer in all your battles is not supreme excellence;
    supreme excellence consists in breaking the enemy's resistance without fighting."
    Art of War Sun Tzu

  2. #2
    & the hat of GPL slaying Thantos's Avatar
    Join Date
    Sep 2001
    Posts
    5,681
    Well remember that C# is a microsoft created language and doesn't have to follow the C++ standard. The best spot to check would be msdn

  3. #3
    essence of digital xddxogm3's Avatar
    Join Date
    Sep 2003
    Posts
    589
    But is it bad form to have main not return an int in c#.
    I understand it is a microsoft derivative of the C family.
    But since it is a strain of the C family, should it also have main return an int?
    I guess this is a very mundane question, but I just want to make sure my code is correct.
    "Hence to fight and conquer in all your battles is not supreme excellence;
    supreme excellence consists in breaking the enemy's resistance without fighting."
    Art of War Sun Tzu

  4. #4
    & the hat of GPL slaying Thantos's Avatar
    Join Date
    Sep 2001
    Posts
    5,681
    Without getting into a flame fest over it, C# is about as close as Java is to C/C++
    So it reality it doesn't matter what C/C++ says, all that matters is what the C# standard says.

  5. #5
    and the hat of int overfl Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    32,822
    > I'm working through C# How to Program Deitel.
    > They write main as static void.
    > Based on the C++ standard, is this valid?
    Well duh!
    C# != C != C++
    Surely you don't believe that every language should have an int main. Pascal doesn't follow the C++ standard either.

    And no, valid C# programs are in no way valid C++ programs, so the point is moot.

  6. #6
    and the hat of int overfl Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    32,822
    > I understand it is a microsoft derivative of the C family.
    No, C# is microsoft java with a new name designed to capture the imagination of a world full of C and C++ programmers as the next best thing to move towards.

  7. #7
    essence of digital xddxogm3's Avatar
    Join Date
    Sep 2003
    Posts
    589
    ok, that makes since.
    I have read in the compiler faq and in this book that it is the evolution of the c family with roots in java and c. but on this forum, everybody openly attacks the idea that it is in relation to either language. That is funny as heck. <<sensorship $ux. thanks for the input thantos.
    "Hence to fight and conquer in all your battles is not supreme excellence;
    supreme excellence consists in breaking the enemy's resistance without fighting."
    Art of War Sun Tzu

  8. #8
    essence of digital xddxogm3's Avatar
    Join Date
    Sep 2003
    Posts
    589
    wow, sorry to bring that up salem.
    I know very little on c#, except what I read on this forum and in the books.
    I agree from the syntax I have read, the only thing I find similar are the loops, decision statement, and general non-language specific syntax.
    "Hence to fight and conquer in all your battles is not supreme excellence;
    supreme excellence consists in breaking the enemy's resistance without fighting."
    Art of War Sun Tzu

  9. #9
    the hat of redundancy hat nvoigt's Avatar
    Join Date
    Aug 2001
    Location
    Hannover, Germany
    Posts
    3,139
    C# is everything that C++ lacks in RAD features. VB had that, too, but who'd want to admit using VB ?

    There is a tool for every job, and C# fits nicely into the client-development role. If I need processing power and fine control I'll use a C++ program, if I need graphics and ease of use, I'll use C#.
    hth
    -nv

    She was so Blonde, she spent 20 minutes looking at the orange juice can because it said "Concentrate."

    When in doubt, read the FAQ.
    Then ask a smart question.

  10. #10
    Banned master5001's Avatar
    Join Date
    Aug 2001
    Location
    Visalia, CA, USA
    Posts
    3,685
    What nvoigt said is exactly right. Someone jump in here if I'm wrong, but java also uses void main() when exporting code to an exe, correct?

  11. #11
    Super Moderator
    Join Date
    Sep 2001
    Posts
    4,913
    Has no one noticed that both of the languages in question use intermediate languages? They're not compiled all the way, so the operating system does not interface directly with your source code. They work with the interpreter of the 'Byte Codes' or the "IRL" or whatever it's called. This could very well be the reason for voiding main.

  12. #12
    S Sang-drax's Avatar
    Join Date
    May 2002
    Location
    Göteborg, Sweden
    Posts
    2,072
    I don't think it as anything to do with that. If you want to return anything to teh OS in java, just use System.exit( code );

    The reason is that most programs (especially GUI) don't use the return code and it is cumbersome to always add a return statement to your program. C++ solves this by adding an implicit return 0 if no return statement is specified, but that is a hack.
    The programs that wish to return something just use System.exit.
    Last edited by Sang-drax : Tomorrow at 02:21 AM. Reason: Time travelling

  13. #13
    the hat of redundancy hat nvoigt's Avatar
    Join Date
    Aug 2001
    Location
    Hannover, Germany
    Posts
    3,139
    They work with the interpreter of the 'Byte Codes' or the "IRL" or whatever it's called.
    C# Code is not interpreted. The Intermediate assembly language is compiled at the client side just in time. There are also tools that compile immediatly. But that is giving away the possibility to optimize for the client computers hardware.
    hth
    -nv

    She was so Blonde, she spent 20 minutes looking at the orange juice can because it said "Concentrate."

    When in doubt, read the FAQ.
    Then ask a smart question.

  14. #14
    flashing vampire black's Avatar
    Join Date
    May 2002
    Posts
    563
    simply checking the grammer, i think C# and Java are more alike than C or C++.
    Never end on learning~

  15. #15
    Banned master5001's Avatar
    Join Date
    Aug 2001
    Location
    Visalia, CA, USA
    Posts
    3,685
    Java/C# are what I call the gray area languages. They are compiled into an interpreted binary. Thus its capable of running faster than lets say a Python script, but is still ultimately being run by another program that interprets its code. I wouldn't quite call them an interpreted languages in the more conventional "scripting language" sort of way, but they are interpreted no less.

Page 1 of 2 12 LastLast
Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Replies: 2
    Last Post: 03-05-2009, 10:25 AM
  2. can someone help me with these errors please code included
    By geekrockergal in forum C Programming
    Replies: 7
    Last Post: 02-10-2009, 02:20 PM
  3. Compiling sample DarkGDK Program
    By Phyxashun in forum Game Programming
    Replies: 6
    Last Post: 01-27-2009, 03:07 AM
  4. need help with handelling multiple source files
    By DarkMortar in forum C++ Programming
    Replies: 38
    Last Post: 05-26-2006, 11:46 PM
  5. getting a headache
    By sreetvert83 in forum C++ Programming
    Replies: 41
    Last Post: 09-30-2005, 06:20 AM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21