Entries:
Comments:
Posts:

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

Creating and Calling Simple Overloaded Helper Methods - 10

Embed code for this video

Copy the code above to embed our video on your website/blog.

Close

Video format

Option selected may change based on video formats available and browser capability.

Close

Download

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...

Tags:

Follow the Discussion

  • 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?

    Thanks.

  • @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))
    
       Console.WriteLine(number);
    
    else
    
    .
    
    .
    
    .

     

    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

    Bob,

    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!

    Kieran

  • 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(name);
    Console.WriteLine("");
    Console.WriteLine("Press any key to continue.");
    Console.ReadLine();

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

    string myValue = superSecretFormula(names[numberChoice]);
    Console.WriteLine(myValue);
    Console.ReadLine();
    }

    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.

    Thanks

  • @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)]);

  • BILALBILAL

    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.

    @Bilal

    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...

Remove this comment

Remove this thread

close

Comment on the Post

Already have a Channel 9 account? Please sign in