Loading user information from Channel 9

Something went wrong getting user information from Channel 9

Latest Achievement:

Loading user information from MSDN

Something went wrong getting user information from MSDN

Visual Studio Achievements

Latest Achievement:

Loading Visual Studio Achievements

Something went wrong getting the Visual Studio Achievements

Content Obsolete

This content is no longer current. We recommend you try the following url for more up to date content: http://channel9.msdn.com/Series/C-Fundamentals-for-Absolute-Beginners

Creating and Calling Simple Overloaded Helper Methods - 10

11 minutes, 28 seconds


Right click “Save as…”

In this video we begin wading into the topic of methods by creating a helper method to break out code we may need to use in multiple places within our code. We create and call our methods to retrieve a value, create and use input parameters, learn about string formatting, and create overloaded versions of our method

Download the source code for Creating and Calling Simple...


Follow the discussion

  • Oops, something didn't work.

    Getting subscription
    Subscribe to this conversation
  • Overloading i learnt today, which i never able to understand going through other site. period.

  • i can't download any vidoes, it says your servers are down! please put it back up  Tongue Out

  • Thanks... The servers are back i can now download this videos  Big Smile

  • KevinKevin

    Just a quick question is there a reason why the methods were written after the program code? Can you write methods first and then call them later?


  • @Kevin: GREAT QUESTION!  First, you can always try stuff like this out on your own -- and you should!  It's a great way to learn the propensities of the environment you're in.  In this case, it does not matter -- you can put the code anywhere.  What matters, as you'll learn soon, is the NAME of the method, both it's method name AND the namespace it belongs to.  The compiler is smart enough to link up a method call -- regardless of where it's defined -- with its definition.  Again, love that question!

  • Great, just a  question. Is any video where you explain ref, out and arrays params for methods? Thanks Bob, your videos and the way how u explain the topics are easy to understand. 

  • @claudioas2001:  Out parameters, yes.  At some point we talk about TryParse and in that video, TryParse will send a converted value as an output parameter.  Unfortunately, I can't recall which video that is in ... someone recently asked for help with it, so look for a long passage / reply from me on TryParse.  It's a simple concept however ... output parameters are a second way to return values from methods (the other way being the 'return' statement).  Just prefix a parameter with out, like so:

    string value;
    double number;
    value = Double.MinValue.ToString();
    if (Double.TryParse(value, out number))


    re: using arrays as input parameters.  Personally, I hate arrays for passing data around in real applications.  I much prefer using generic collections.  I believe I do talk about generic collections near the end of this series and in more depth on my website (see the C# for Absolute Beginner's series, day 5).  Hope that helps!

  • KieranKieran


    Regards from Ireland!

    Loved your videos, you are a fantastic teacher. Where would you recommend to go from here as far as learning materials go?

    Thanks for the great series!


  • TesfayeTesfaye

    Bob, while wandering through so many programming courses, I have long strugled to understand basics of programing. Bob, you are simply best!!

  • I love the length of these videos. It's great to throw a little quick learning in every day. Thanks!

  • @Kieran: Sorry for the delayed response.  I'm constantly creating new content / entire courses on my own site if you like my style.  www.learnvisualstudio.net ... hope I can help! -Bob

  • BillBill

    Thank you,Bob; you are a fantastic teacher, and the content is A+++. You take a subject which is like Greek to the neophyte and make it logical and understandable. 5 Stars!!!

  • paekyawpaekyaw

    Thank you,BoB.

  • rajuraju

    all videos are ********
    thanks bob

  • @Bill:  @paekyaw:  Thank you, much appreciated.

    @raju: I hope ******* is a good thing?  Smiley

  • fifififi

    just got to understand the concept of overloading...thanks bob you make it seem so simple and straight forward..

  • Thank you for the video.

  • thanx..BoB..

  • DDom23DDom23

    Why doesn't this work? I'm probably doing something stupidly wrong.

    using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Text;

    namespace TestingTesting
    class Program
    static void Main(string[] args)
    string[] names = {"Bobby", "Steve", "Chad", "Bart"};

    foreach (string name in names)
    Console.WriteLine("Press any key to continue.");

    string numberChoice;
    Console.WriteLine("Choose a number between 0 and 3:");
    numberChoice = Console.ReadLine();

    string myValue = superSecretFormula(names[numberChoice]);

    private static string superSecretFormula(string name)
    return string.Format("Hello World, and {0}.", name);

  • @DDom23: What is the error message you are getting?  Which line does the error message reference?  Or are you simply getting results you did not anticipate?

  • DDom23DDom23

    Its ok now. I forgot that readline forms a string and had to convert it using convert.toint32 before I could use it.

  • DineshDinesh

    Hi Bob,

    Order of parameters also matters, for example
    SuperSecretFormula(string name, int age) is different from
    SuperSecretFormula(int age, string name)

    So Number, Type and Order of parameters are considered in Method overloading.


  • @Dinesh: Yep, order matters.  Smiley

  • Tenho grande dificuldade no ingles... Mas quem quer consegue.

  • JG  HayesJG Hayes

    WHOA! I just wanna say I got my start watching your videos back when I started programming in '08, it's awesome to see you again!

  • NIthinNIthin

    Hi bob,
    your tutorial is great. i am in need of creating an app for tablet running windows 7 OS. what all tools or SDK's will i need to set up before creating one other than visual studio?? and if a Winforms app enough to run on tablet?? i need your help in that..thanks in advance...

  • @JG Hayes:Awesome ... are you still writing code?  Let me know what you're up to!

    @NIthin: I'm really sorry, but I have absolutely no knowledge in what you're asking.  If it's an old-style tablet it should "just work" ... the OS takes care of pen / virtual keyboard input ... I think.  Again, I'm not the guy to ask about that. Sorry!

  • AkramAkram

    Hi bob

    I am just a beginner in Programming well i saw your few videos and i would like to be learn c sharp .Please if you would recommend me to go through your video which will help me to learn c sharp for future.

  • @Akram: Hi, I may not completely understand what you are asking.  However, I would say just start here and watch them all, and be sure to follow along.  Once you finish this entire series, you'll have the basics and can move on to learn more about (1) composing classes / delegating responsibilities / designing interactions, etc.  (2) the .NET Framework APIs for things like data access, some front end client technology like WPF or ASP.NET WebForms or MVC.  Could you clarify your question?  I'd be glad to point you in the right direction if I can.

  • milanmilan

    Hi Bob,

    Thanks for putting so much efforts and making these videos. The videos are awesome.

  • @DDom23:  Error is in the below line

    string myValue = superSecretFormula(names[numberChoice]);

    numberChoice is an string variable, You need to use int.Parse method to covert it into int. replace that code with below.

    string myValue = superSecretFormula(names[int.Parse(numberChoice)]);


    How can i download core c# course complete videos??

  • Hi Bob,

    I have been going through your video every chance I get, all day long when possible.

    Its very rewarding and comprehensible. Although, the "Buffering" is annoying.  What can I do, other than pausing it for the buffering to catch up?  It interferes with my train of thought, especially when you are sharing a new concept for me.


    I would like to download the video as well and have been unsuccessful.


  • Great Lesson on calling the same method with different versions. I can already see how to apply this in a real world setting.

  • L CatL Cat

    I love your holly videos, you are the only fantastic C# God for me as I am just a zero beginner and watched your videos for WinPhon7! I have already coded one application...

  • L CatL Cat

    I love your holly videos, you are the only fantastic C# God for me as I am just a zero beginner and watched your videos for WinPhon7! I have already coded one application...

  • NheryNhery

    Guys just restart your computer is its buffering. works for me

  • HslsHsls

    Great videos and even I learn much from them! Thanks!

    However, is the camelCase naming of the methods intentional? According to Microsoft naming conventions for .NET PascalCasing should be used for methods. http://msdn.microsoft.com/en-us/library/vstudio/ms229043.aspx

  • You mentioned in the video that you would explain why you had to define the helper methods as static. I read that you only need to define methods as static if the class is defined with static. Maybe my source of information was wrong.

    Could you correct me on the why you needed to use the static keyword on the help methods.

  • Clint RutkasClint I'm a "developer"

    @carlwain74: Since this application is a basic console application, since Main must be a static method, any method that it calls must be a static as well.

    You don't have to have a static class to have static methods as well in c# at least

  • But the helper function needed to be static in addition to main. This is something I don't understand.

  • Clint RutkasClint I'm a "developer"

    @carlwain74: it does.  Since main is a static function, it can only access static members / functions from within its own class.  If you create a new object like StreamReader from within main, you can call non-static members on that new object.  But any method or member within the Main here since it has to be declared as a static must be static as well to be accessed.


    Once you go to a non-console application, this goes away as well since they are not static by nature

  • @Clint:Thanks for the explanation.. Now I understand.

  • Hello Bob, First I've been following tutorials on MSDN 9. THANK YOU & CLINT & Ms.GOLNAZ !!! I can't tell you how UNDERSTANDABLE you've made C# for me ( and a million others ) !
    My 'mystery' is : simple console program runs a method , declared Outside the "Main" codeblock ( see in the screenshot 2 private methods ) Nowhere OUTSIDE of the method do I run Console.WriteLine() , BUT my method ("Print_Number()") RUNS & prints to console. I was expecting to see a blank screen. Actually started w/ "Console.WriteLine( abc + "\n" + xyz ) " & xyz was printing to console window first. I would think I'd get a "Variable Declared but Never Used" exception...
    Oh & I hit Clean Solution, Rebuild Project , Closed & Restarted Proj. & Visual Studio , moved methods below "MAIN" block, have not gone back & made methods 'static',still experimenting with constructor method
    Any thoughts greatly appreciated , Thanks
    Ben ( using VisualStudio 2012 Express on Windows 7 Home Pre. , 8 Gb Corsair memory , iCore 7 cpu )

    namespace SimpleMethodLsn
        class Program
            private string HelloWorld ( )
                return "Hello World Method is Called Here";
            private int Print_Number ( )
                Console.WriteLine ( "This line is inside the Print_Number Method " );
                return 101;
            static void Main ( string [ ] args )
                Program p = new Program ( );
                string abc = (p.HelloWorld() );
                int xyz = ( p.Print_Number ( ) );
                Console.ReadLine ( );

    Hope this isn't being too much of a pain, don't see where to post a screenshot.Thanks again.

  • Clint RutkasClint I'm a "developer"

    @SteveHtml: first, we're trying to keep the comments to the topic of the video, here is it overloads.

    First, there are things to help debugging like breakpoints and Debug.Writeline(string) method that can help figure out what is going on.

    Next, Console.WriteLine is called, it is called in your Print_Number method.  What you're doing is allowed.

  • SteveHtmlSteveHtml

    @Clint : Wow , Thanks Man for the responce, didn't really expect one @ this late date ( or so soon ).
    You said " keep the comments to the topic of the video, here is it overloads." , for that I apologize Clint, you guys just shed a lot of light on things I've studied but never really grasped, so again apologies ( will keep on topic from now on ! ) Thank you for taking the time, just seemed the craziest thing to me.... Thanks Clint!

  • BuchiBuchi

    Hi Bob
    Thanks a lot for these video. please do you have any video on ASP.net
    I need it.

  • FirebatFirebat

    You are a truly excellent tutor. I was starting to think that programmers make bad teachers until I found this video series. Thank you very much, sir.

  • Edwin jEdwin j

    Hi, what is an "input parameter"?

  • Clint RutkasClint I'm a "developer"

    @Edwin j: been a while since I watched the videos so my context may be slightly off.  An input parameter is a variable that takes in data.  INput versus OUTput.  This terminology would typically be used with method calls where we would expect to pass in data, like if I had "public int CalculateCoffeeCupSize(int ouncesOfCoffee)", ouncesOfCoffee is an input parameter and it returns an int as an output parameter

  • Great video

  • {
    string myValue = superSecretFormula("Mery");
    myValue = superSecretFormula("Philip");
    private static string superSecretFormula(string name)
    return String.Format("Hello, {1}", name);

    This gives me a popup when I try to debug it:

    An unhandled exception of type 'System.FormatException' occurred in mscorlib.dll

    Additional information: Index (zero based) must be greater than or equal to zero and less than the size of the argument list.

    figured out I had to change change this line:

    //return String.Format("Hello, {1}", name);
    return String.Format("Hello, {0}", name);

    But why?

  • sadiqsadiq

    i want to learn c# any body help me?

  • RyanRyan

    How come the 2nd call:

    myValue = superSecretFormula("Steve");

    only works without "string" preceding it?

  • @BobTabor:

    Dear Bob,First thanks for your video!

    there have some question:

    Why the "stantic viod Main()"have parameters "string" named "args"?

    Have some place to use this?

    Is them result to we must convert some variable?

    thanks argain.:)

  • Size3Size3 vb.net developer branching out into c#.net

    @sadiq: For the absolute beginner this is exactly the place to start.


Remove this comment

Remove this thread


Comments closed

Comments have been closed since this content was published more than 30 days ago, but if you'd like to continue the conversation, please create a new thread in our Forums, or Contact Us and let us know.