Like Tree1Likes
  • 1 Post By itsme86

Noob question

This is a discussion on Noob question within the C# Programming forums, part of the General Programming Boards category; How do I get it to return a string properly Code: namespace Lab1race { class Bet { public int Amount; ...

  1. #1
    Registered User
    Join Date
    Dec 2008
    Posts
    20

    Noob question

    How do I get it to return a string properly



    Code:
     namespace Lab1race
    {
        class Bet
        {
            public int Amount;
            public int Dog;
            public Guy Bettor;
    
            public string GetDescription()
            {
                
                return (Bettor.Name + "bets" + Amount + "  on Dog" + Dog); 
            }
        }
    }

  2. #2
    ATH0 quzah's Avatar
    Join Date
    Oct 2001
    Posts
    14,826
    Probably:
    Code:
     namespace Lab1race
    {
        class Bet
        {
            public int Amount;
            public int Dog;
            public Guy Bettor;
    
            public string GetDescription()
            {
                string desc = Bettor.Name + "bets" + Amount + "  on Dog" + Dog; 
                return desc;
            }
        }
    }
    That looks about right.


    Quzah.
    Hope is the first step on the road to disappointment.

  3. #3
    Gawking at stupidity
    Join Date
    Jul 2004
    Location
    Oregon, USA
    Posts
    3,175
    String.Format() is nice for compound strings like this. It keeps it a little more readable:
    Code:
    return String.Format("{0} bets {1} on dog {2}", Better.Name, Amount, Dog);
    quzah likes this.
    If you understand what you're doing, you're not learning anything.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. noob question
    By dhuan in forum C++ Programming
    Replies: 1
    Last Post: 11-02-2010, 06:00 AM
  2. NOOB Question!
    By Paul22000 in forum C Programming
    Replies: 4
    Last Post: 04-23-2008, 12:58 PM
  3. Another Noob Question
    By Nightwarrior in forum C++ Programming
    Replies: 10
    Last Post: 10-13-2007, 02:03 PM
  4. Very noob question :(.
    By GamerProduction in forum Tech Board
    Replies: 4
    Last Post: 04-14-2007, 06:40 AM
  5. Just another noob question
    By verbity in forum C++ Programming
    Replies: 9
    Last Post: 03-25-2007, 11:02 AM

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