C# Programming Tutorial 73 - Intro to Static Methods

preview_player
Показать описание


~~~~~~~~~~~~~~~ CONNECT ~~~~~~~~~~~~~~~

~~~~~~~~~~~~~~ SUPPORT ME ~~~~~~~~~~~~~~

🅑 Bitcoin - 3HnF1SWTzo1dCU7RwFLhgk7SYiVfV37Pbq
🅔 Eth - 0x350139af84b60d075a3a0379716040b63f6D3853
Рекомендации по теме
Комментарии
Автор

You are nice in teaching c#, I'm learning from your series and keep it up

mahnooraltaf
Автор

I love the tutorial from start to finish but i think when you get to classes, you should split some of the content. I know you erase the methods & adjust the same classes. Which is fine but from the people watching the videos we are actually keeping what you did prior. for example, every time you adjusted the user class dramatically & just erased it i would create a new user class. I lost you once i got to video 71. To much clutter. Again amazing amazing tutorial series. I can not stress that enough. Im just trying to avoid having multiple user classes. Ill give you an example of my main for reference. Some of the methods have a different name then yours.
using System.Collections.Generic;
using static System.Console;

namespace ClassesTutorial {

class Program
{

static void Main ()
{
Classes

// Playing around with a function that
// Creates new 'User' singletons

var myProgram = new Program();// Instantiates
// Will output default first name to lower case
myProgram.LetsCreateObj();

// Playing around with a function that
// Creates new 'User' singletons


WriteLine Classes

// Encapsulation to gate properties
// to our fields getters|setters

myProgram.LetsCreateObj2();

// resetting FirstName
var reset = new User2GettersSetters {
FirstName2 = "GOLIATH"
};
var fName = reset.FirstName2;
WriteLine($"New value for the `FirstName` property is\n" +
$"[ {fName} ]");


// Encapsulation to gate properties
// to our fields getters|setters


WriteLine Classes

// List of custom class | creating custom types in
// a loop & adding to List

// Returns a list of user objects
// full name.
myProgram.DoSomething();



// Iterates through two List<string>
// of type user objects



// List of custom class | creating custom types in
// a loop & adding to List


WriteLine Classes

// Sorting an array with C# built in library


WriteLine Classes

}

// <[V#1]>

public void LetsCreateObj() {
var me = new User {
FirstName = "Alias111",
LastName = "The Great One"
};
// Has to be assigned to a variable since
// the method is returning a string
var msg = me.OutputStr(2);
// Then WriteLine 'msg'
WriteLine(msg);
}

// <[V#2]>

public void LetsCreateObj2() {
var me = new User2GettersSetters {
LastName2 = "The Great One"
};
// Has to be assigned to a variable since
// the method is returning a string
var msg = me.OutputStr(1);
// Then WriteLine 'msg'
WriteLine(msg);
}

// <[V#3]>

public void DoSomething() {
User me = new User {
FirstName = "Tido",
LastName = "JuanBobo"
};

var you = new User() {
FirstName = "Billy",
LastName = "Bob"
};
var users = new List<User> { me, you };
// To access the properties in User
foreach ( User peeps in users) {
WriteLine("Will output users 'me' & 'you'\n" +
$"{peeps.OutputStr(1)}");
}
}

// <[V#3]>

public void DoSomethingForList() {
var aList_Of_FNames =
new List<string> {
"Alias111",
"Alisia",
"Jose"
};

var aList_Of_LNames =
new List<string> {
"Martin",
"Jones",
"Jagbby"
};

var users = new List<User>();
// To access the properties in User
for ( var i = 0; i < aList_Of_FNames.Count; i++) {

User fullName = new User {
FirstName = aList_Of_FNames[ i ],
LastName = aList_Of_LNames[ i ]
};
users.Add(fullName);
}

foreach ( User user in users) {
WriteLine("List returns full name:\n" +
$"{user.OutputStr(1)}");
}
}

// <[V#3]>

public void TakeUser(User user) {
user.OutputStr(1);

}
}
}

alias_onedepapel