Results 1 to 14 of 14

Thread: C# Anyone?

  1. #1
    Only plays for sport Unknown Entity's Avatar
    Join Date
    Feb 2008
    Location
    Hiding behind your smile.
    Age
    32
    Posts
    4,052
    Blog Entries
    29

    C# Anyone?

    I got on a computer programming course, and it seems to be ok so far. However, I'm having a little trouble learning the language C#.

    I was wondering if there was anyone on here who has worked with/knows this computer language, and if they wouldn't mind helping me out a little bit.

    Maybe if you have any tips, could you post them here? It would be a great help!


    "I used to be active here like you, then I took an arrow in the knee."
    >>>------------->

    Suddenly... clutter.:

    Me and the lovely Joey is two cheeky chimpmonks, we is. Because TFF cousins can still... do stuff. ; )



    Quotes to have a giggle at.:

    Quote Originally Posted by Bleachfangirl
    I'm none too scary really. Just somewhat violent...
    Quote Originally Posted by MSN Convo
    Gemma the friggin' Entity. says:
    ^^;
    brb
    Bleachie says:
    Kay
    ...*runs around with a stick*
    I AM SPARTACUS!!!
    Hm, no one's here...
    TIME TO PARTY!
    Wheeeeeeeeeeeeeeeeeeeeeeeeee
    Gemma the friggin' Entity. says:
    back
    Bleachie says:
    DARN IT
    Quote Originally Posted by Joe
    Now that we've apparently discussed wanting to see each other sleep with a game character... how goes?

    All my banners are now done by me! Soon, I will be great! Muwahahahaha... ha... eck! *coughs* ...ha!
    Biggest fan of Peanut Butter created by The Xeim and Halie Peanut Butter Corporation ^^



    Warning free for over eight years. Feels good.

  2. #2
    Magically Delicous C# Anyone? Merlin's Avatar
    Join Date
    Jan 2001
    Location
    Quel'thalas
    Age
    42
    Posts
    11,159
    I haven't touched it in a while, but I can help out if you need it. I'm quite proficient in C-based languages so ask away.

    As for tips, it would depend on your experience level with programming in general and what the level of the class is. I don't want to start preaching about the proper use of curly-braces and semi-colons if you are way beyond that... haha.

    Also, what kind of topics are actually being covered? Is it all command-line or GUI stuff as well? Or is it C# in ASP.NET? C# is used for multiple things in .NET and they are totally different topics. ^_^

    Anyways, just let me know some more info or specifics on what you need help with.

  3. #3
    ...means nothing to no way Furore's Avatar
    Join Date
    Mar 2007
    Location
    F*ckin' Australia!
    Age
    35
    Posts
    4,220
    Code:
    /* Jesus loves drunks like I like C#. Even if I do suck with it a good deal. */
    using System;
    namespace drunk
    {
        class drunk
        {
            static void Main() 
            {
                System.Console.WriteLine("Drunker than a camel with humps full of rum.");
    
                // Keep the console window open in debug mode.
                System.Console.WriteLine("Press any key to sober up.");
                System.Console.ReadKey();
            }
        }
    }
    C#'s fun.
    victoria aut mors

  4. #4
    私は。。。思い出にはならないさ C# Anyone? chaosweapon's Avatar
    Join Date
    Feb 2006
    Location
    Europe
    Age
    35
    Posts
    172
    I will start learning C from next week or the one after as part of my engineering course. It seems like it resembles Java.

    Can someone please explain the static void main? I've used it a couple of times but I don't know what it means.

  5. #5
    Only plays for sport Unknown Entity's Avatar
    Join Date
    Feb 2008
    Location
    Hiding behind your smile.
    Age
    32
    Posts
    4,052
    Blog Entries
    29
    LOL Silver! Will that one work if I start to debug?

    Quote Originally Posted by Tech Support View Post
    I haven't touched it in a while, but I can help out if you need it. I'm quite proficient in C-based languages so ask away.

    As for tips, it would depend on your experience level with programming in general and what the level of the class is. I don't want to start preaching about the proper use of curly-braces and semi-colons if you are way beyond that... haha.

    Also, what kind of topics are actually being covered? Is it all command-line or GUI stuff as well? Or is it C# in ASP.NET? C# is used for multiple things in .NET and they are totally different topics. ^_^

    Anyways, just let me know some more info or specifics on what you need help with.
    Thank you so much! I know about the curly-braces and semi-colons lol... Its the actual maths in the processing I'm really having the trouble with. I know how to do the inputs and outputs - they are to simple to even be real - but the process... Either I'm really bad at maths, or I'm just not creative enough to work out some kinda order to my process.

    The task we've been given was to make a program which converts cm into inches (1cm = 2.57inches). The thing is, I'm not sure about the symbols I should be using for this (* / - ...). Now, as I need to work this out on my own, I don't want an answer - just a little guidence to push me on the right path. Mainly because so far all I have is:

    Code:
    //process
                lenin = lencm;
    LOL! So please, just a little nudge...

    EDIT: Ok... Is this ANYWHERE near rightish?

    Code:
    //process
                1 = 2.57 / 2.57;
    And good luck chaosweapon! Haha, we'll be kinda in the same boat, but I think you may have better luck than me if you've worked with Java...

    EDIT: Silver, that had more build errors than my first program lol!
    Last edited by Unknown Entity; 10-02-2008 at 01:19 PM.


    "I used to be active here like you, then I took an arrow in the knee."
    >>>------------->

    Suddenly... clutter.:

    Me and the lovely Joey is two cheeky chimpmonks, we is. Because TFF cousins can still... do stuff. ; )



    Quotes to have a giggle at.:

    Quote Originally Posted by Bleachfangirl
    I'm none too scary really. Just somewhat violent...
    Quote Originally Posted by MSN Convo
    Gemma the friggin' Entity. says:
    ^^;
    brb
    Bleachie says:
    Kay
    ...*runs around with a stick*
    I AM SPARTACUS!!!
    Hm, no one's here...
    TIME TO PARTY!
    Wheeeeeeeeeeeeeeeeeeeeeeeeee
    Gemma the friggin' Entity. says:
    back
    Bleachie says:
    DARN IT
    Quote Originally Posted by Joe
    Now that we've apparently discussed wanting to see each other sleep with a game character... how goes?

    All my banners are now done by me! Soon, I will be great! Muwahahahaha... ha... eck! *coughs* ...ha!
    Biggest fan of Peanut Butter created by The Xeim and Halie Peanut Butter Corporation ^^



    Warning free for over eight years. Feels good.

  6. #6
    ...means nothing to no way Furore's Avatar
    Join Date
    Mar 2007
    Location
    F*ckin' Australia!
    Age
    35
    Posts
    4,220
    Quote Originally Posted by Unknown Entity View Post
    EDIT: Silver, that had more build errors than my first program lol!
    It was a semi-drunk joke.
    Considering I wrote it in a couple minutes as a joke I'd be surprised if it did really work.

    I thought it was a beautiful artistic expression.
    victoria aut mors

  7. #7
    Magically Delicous C# Anyone? Merlin's Avatar
    Join Date
    Jan 2001
    Location
    Quel'thalas
    Age
    42
    Posts
    11,159
    Quote Originally Posted by chaosweapon View Post
    ICan someone please explain the static void main? I've used it a couple of times but I don't know what it means.
    A static method, field, property, or event is callable on a class even when no instance of the class has been created. If any instances of the class are created, they cannot be used to access the static member. Only one copy of static fields and events exists, and static methods and properties can only access static fields and static events. Static members are often used to represent data or calculations that do not change in response to object state; for instance, a math library might contain static methods for calculating sine and cosine.

    void simply means that the method returns nothing. You can have an int method that would return an int, for instance. Void methods do not return anything at all.

    So, what does this all mean? The main method is static for multiple reasons. The easy explaination is because it's the method called at the start of the program before any others that you create. I could go into a lengthy discussion explaining the difference between static and instance members, but that is probably beyond the scope of where you are at this moment. Basically, if you make a method static, it's the same every time you call it. For a variable, if it is static, it is the same no matter how many copies of that class you make. If you change that variable in one of the instances, it changes in all of them.


    Quote Originally Posted by Unknown Entity View Post
    The task we've been given was to make a program which converts cm into inches (1cm = 2.57inches). The thing is, I'm not sure about the symbols I should be using for this (* / - ...). Now, as I need to work this out on my own, I don't want an answer - just a little guidence to push me on the right path. Mainly because so far all I have is:
    Well there's multiple ways to do it really. You can have a variable that has the upconversion rate in it or write a method to do it.

    Here's a simple method that would do it:
    Code:
        public static double CentimetersToInches(string input)
        {
            // Convert argument to double for calculations.
            double c = System.Double.Parse(input);
    
            // Convert Centimeters to Inches
            double i = (c * 2.57);
    
            return i;
        }
    OR:
    Outside of your main method (inside the main class):
    Code:
    static final double CENTIMETERSTOINCHES = 2.57;
    then just take your input and multiply:
    Code:
    double i = input * CENTIMETERSTOINCHES;

    I think your main hangup is you don't seem to know how to use variables yet. All your calculations are typically done with variables. Well you could technically do the whole program with none, but that'd be a mess and nobody would want to debug it:
    Code:
    System.Console.Writeln("Input the number of centimeters:");
    System.Console.Writeln("Centemeters to inches is {0}", (System.Double.Parse(System.Console.ReadLine())* 2.57);
    Yeah, I'd bust you upside the head for writing something like that. Variables are what you use to store values and information. Use them!

    Double is your standard floating-point number variable. If you need to store a number with decimals, use double. Int is used for your typical non-floating-point numbers... ie: it does not store decimals. Keep that in mind... because it WILL screw up your calculations if you don't.

    Code:
    System.Console.Writeln("5 / 2.2 is: " + ((int)5 / (int)2.2));
    //5 / 2 is: 2
    Stuff like that will screw you over every time. Don't depend on the compiler to tell you. Many cases it will flag it as "loss of precison". If it does, you are trying to dump a bigger value into the wrong sized container... like a golf ball through a garden hose. It doesn't fit. You can make it fit, but it's not going to be pretty.

  8. #8
    Oh god. I did visual basic in high school, and it was A LOT of fun, but it was quite difficult. I poked around with C++ and Java, but it was waaaay over my head. I wish the best of luck to you.


    98% of teens have tried smoking pot and drinking. If you're one of the 2% who hasn't, copy this and put it in your signature.

  9. #9
    Magically Delicous C# Anyone? Merlin's Avatar
    Join Date
    Jan 2001
    Location
    Quel'thalas
    Age
    42
    Posts
    11,159
    VB is the simplest language you can learn, besides BASIC. It really should only be taught to non-majors, IMHO. I always get a good laugh when people start bragging that they are certified in Visual BASIC or swear by that language. They honestly think it's a hardcore programming language and that they are doing something elite. Um... no. It has the word "basic" in it for a reason.

    But enough of my soap box, if you need programming help I can do that. I won't post the entire code for completing something, but I will give you the necessary tools to help you learn and figure problems out. Most of the time you spend programming is debugging. You've got to learn from the start how to do it or else you'll never succeed.

  10. #10
    Only plays for sport Unknown Entity's Avatar
    Join Date
    Feb 2008
    Location
    Hiding behind your smile.
    Age
    32
    Posts
    4,052
    Blog Entries
    29
    Thanks for all your help Tech Support! I shoulda replied earlier, but I was scared that I'd never work it out...

    But I worked out how to do it! O_O

    I wrote a program on how to divide any number by 12!

    Code:
                int stnumber;
                int ndnumber;
    
                //input
                Console.WriteLine("Enter number to be divided >");
                stnumber = int.Parse(Console.ReadLine());
    
                //process
    
                ndnumber = stnumber / 12;
    
                //output
                Console.WriteLine("Answer is {0}:", ndnumber);
                Console.ReadLine();
    Last edited by Unknown Entity; 10-09-2008 at 01:59 PM.


    "I used to be active here like you, then I took an arrow in the knee."
    >>>------------->

    Suddenly... clutter.:

    Me and the lovely Joey is two cheeky chimpmonks, we is. Because TFF cousins can still... do stuff. ; )



    Quotes to have a giggle at.:

    Quote Originally Posted by Bleachfangirl
    I'm none too scary really. Just somewhat violent...
    Quote Originally Posted by MSN Convo
    Gemma the friggin' Entity. says:
    ^^;
    brb
    Bleachie says:
    Kay
    ...*runs around with a stick*
    I AM SPARTACUS!!!
    Hm, no one's here...
    TIME TO PARTY!
    Wheeeeeeeeeeeeeeeeeeeeeeeeee
    Gemma the friggin' Entity. says:
    back
    Bleachie says:
    DARN IT
    Quote Originally Posted by Joe
    Now that we've apparently discussed wanting to see each other sleep with a game character... how goes?

    All my banners are now done by me! Soon, I will be great! Muwahahahaha... ha... eck! *coughs* ...ha!
    Biggest fan of Peanut Butter created by The Xeim and Halie Peanut Butter Corporation ^^



    Warning free for over eight years. Feels good.

  11. #11
    Magically Delicous C# Anyone? Merlin's Avatar
    Join Date
    Jan 2001
    Location
    Quel'thalas
    Age
    42
    Posts
    11,159
    >_>

    5/12 = 0.4166666666666_
    But your prog will give : 5/12 = 0.

    If you're only allowed to use integers that is fine, but you'll always have truncation(the decimals are chopped off), which means your results will only be accurate if the entered number is evenly divisible by 12. Try lots of numbers and see.

    Always use double if your result has the possibility of having decimals.

    In other news, while you can name variables whatever the heck you want, it's always a good idea for clarity sake to name them something easily understandable/readable by anyone like numerator, total, inNum, outNum, etc. It's just a recommendation, but teachers will love you and when you have to check your code for errors, it makes it so much easier. Trust me, when you get to a lot of lines of code, you won't remember what the heck ndnumber was for. ^_^

    edit: Oh do remember my point from my previous post... if you make 'ndnumber' into a double, it will still be wrong. An integer divided by an integer placed in a double is still an integer...then it adds .0 after it. ie:
    ndnumber = 0.0

    You can easily get around that though. just add a .0 to 12.

    Code:
                int stnumber;
                double ndnumber;
    
                //input
                Console.WriteLine("Enter number to be divided >");
                stnumber = int.Parse(Console.ReadLine());
    
                //process
    
                ndnumber = stnumber / 12.0;
    
                //output
                Console.WriteLine("Answer is {0}:", ndnumber);
                Console.ReadLine();
    But like I said, if your teacher wants only integers, then your code is fine. I know a lot of teachers like forcing students to use rudementary variable types first to "prove" what I have already explained to you... that integers fark up decimal calculations. Guess what you already learned it from me!

  12. #12
    Only plays for sport Unknown Entity's Avatar
    Join Date
    Feb 2008
    Location
    Hiding behind your smile.
    Age
    32
    Posts
    4,052
    Blog Entries
    29
    Lol, thanks again! I knew it wasn't right (cheated and used a calculater... ^_^;, but at least I was half way there. My teacher never told us about adding a ".0"... Could prove useful though!

    Thankies!


    "I used to be active here like you, then I took an arrow in the knee."
    >>>------------->

    Suddenly... clutter.:

    Me and the lovely Joey is two cheeky chimpmonks, we is. Because TFF cousins can still... do stuff. ; )



    Quotes to have a giggle at.:

    Quote Originally Posted by Bleachfangirl
    I'm none too scary really. Just somewhat violent...
    Quote Originally Posted by MSN Convo
    Gemma the friggin' Entity. says:
    ^^;
    brb
    Bleachie says:
    Kay
    ...*runs around with a stick*
    I AM SPARTACUS!!!
    Hm, no one's here...
    TIME TO PARTY!
    Wheeeeeeeeeeeeeeeeeeeeeeeeee
    Gemma the friggin' Entity. says:
    back
    Bleachie says:
    DARN IT
    Quote Originally Posted by Joe
    Now that we've apparently discussed wanting to see each other sleep with a game character... how goes?

    All my banners are now done by me! Soon, I will be great! Muwahahahaha... ha... eck! *coughs* ...ha!
    Biggest fan of Peanut Butter created by The Xeim and Halie Peanut Butter Corporation ^^



    Warning free for over eight years. Feels good.

  13. #13
    TFF'S RESIDENT DOOM GOD C# Anyone? IRANianCha0s's Avatar
    Join Date
    Jun 2006
    Location
    Arlington, TX
    Age
    37
    Posts
    193
    Quote Originally Posted by Silver View Post
    Code:
    /* Jesus loves drunks like I like C#. Even if I do suck with it a good deal. */
    using System;
    namespace drunk
    {
        class drunk
        {
            static void Main() 
            {
                System.Console.WriteLine("Drunker than a camel with humps full of rum.");
    
                // Keep the console window open in debug mode.
                System.Console.WriteLine("Press any key to sober up.");
                System.Console.ReadKey();
            }
        }
    }
    C#'s fun.
    I approve of this code.
    #include stdio.h
    int main () {
    printf("http://www.youtube.com/watch?v=HsqqtgxdKkY");
    return 0; }



  14. #14
    Like a Boss Sean's Avatar
    Join Date
    Jul 2001
    Location
    Saint Louis, Missouri
    Age
    38
    Posts
    5,616
    Someone mind explaining to me the difference between C, C+, C++, and C#? All I have any experience in is Pascal, BASIC, and vBasic, and that was 4+ years ago. :\

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •