Results 1 to 14 of 14

Thread: C# Anyone?

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Only plays for sport Unknown Entity's Avatar
    Join Date
    Feb 2008
    Location
    Hiding behind your smile.
    Age
    34
    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.

  2. #2
    ...means nothing to no way Furore's Avatar
    Join Date
    Mar 2007
    Location
    F*ckin' Australia!
    Age
    36
    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

  3. #3
    Magically Delicous Merlin's Avatar
    Join Date
    Jan 2001
    Location
    Quel'thalas
    Age
    43
    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.

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
  •