Quantcast
Channel: Cemetech
Viewing all articles
Browse latest Browse all 75829

TI-Freak8x :: RE: VS C# Usage & Learning

$
0
0
Author: Compynerd255
Posted: 31 Oct 2012 09:33:36 pm (GMT -5)

But of course. Your class is called Program, therefore it should be renamed OneMethod for your code to work (if you look at the sample more closely, you will see that the class is called OneMethod).

You can continue in this tutorial, but you should know that this code is actually really bad, and a little correction will make it much better:


Code:

// all the same usings go here

namespace OneMethod
{
  class Program
  {
    // insert main() verbatim, as is written in program
  }

  class OneMethod // this name takes precedence over the namespace
  {
    // insert getChoice() verbatim,
    // BUT put a "public" before the start of the method signature
    // so that it can be accessed from Program
  }
}

Simply put, this code encapsulates the getChoice method in a separate object from Program. Typically, your program has one class that contains nothing but a Main method and any other "static" methods to help it out, usually called the Program class. The Program class's only responsibility is to set up the program flow, and should certainly never create instances of itself.
_________________
Visit Betafreak Games: http://www.betafreak.com
Help Me Pay for College:
- Sign up for Fastweb through my referal link!


Viewing all articles
Browse latest Browse all 75829

Latest Images

Trending Articles



Latest Images