Welcome!

By registering with us, you'll be able to discuss, share and private message with other members of our community.

SignUp Now!
  • Guest, before posting your code please take these rules into consideration:
    • It is required to use our BBCode feature to display your code. While within the editor click < / > or >_ and place your code within the BB Code prompt. This helps others with finding a solution by making it easier to read and easier to copy.
    • You can also use markdown to share your code. When using markdown your code will be automatically converted to BBCode. For help with markdown check out the markdown guide.
    • Don't share a wall of code. All we want is the problem area, the code related to your issue.


    To learn more about how to use our BBCode feature, please click here.

    Thank you, Code Forum.

C# Please help me with list <>

MRR

New Coder
I understand List in C# but How it works when it's functioning with Public class.
Can you explain the following code So I clear my confusion?

20.png
 
GetBrowsers is a function that returns a List of BrowserVersion objects
its first line creates a variable whose type is List of BrowserObjects, and creates an empty instance of that type
 
If you understand C# lists as you write, and @JavaJames already explained everything there is to these two lines of code, why do you still need a tutorial ? What exactly is confusing you about them ? Do you know the basics of C#, such as classes, public and private functions ?
 
Is it the < > notation that’s confusing you? If so…
with an ordinary List you can put any kind of object into it, and have no guarantees about what kind of object you will get when you retrieve from the List.
By adding a class name in < > you specify that the list can only contain objects of that class. Eg List<String> says that the list can only contain Strings. The compiler will prevent you putting anything else in, and will know that anything you retrieve from the list will be a string.
This all makes your code shorter, clearer, and far less prone to errors.
 
Back
Top Bottom