39 Replies
you're not going to get much help if you don't ask a question
ok I am trying to create a list that contains 4 strings per list
I dont know why my check function isnt working
were you the one asking about lists of tuples yesterday too
yes
you advised me to put it in a class
ok so you're on the right track to take those 4 strings and encapsulate them into a class
but you didn't do it quite right
yah Im kind of new to C#
the strings represent an account's name, website, login, and password, which you have as fields of that class
been using java more but transitioned
but then you also have a list of a 4-tuple of strings in there too
the
Accounts
class should really be the Account
class
and then you would have a List<Account>
instead of the list of tuples
and that list would be outside the classit should be called the Account class because I am creating one account at a time?
yes exactly
oh okay
the class only represents one account
if you want to hold multiple, you put them in a list, which you are doing, but the list shouldn't be part of the class
a class to its members is a "has a" relationship. e.g. an account has a name, website, login, and password
but why would an account "have a" list of accounts?
it wouldnt
yup
Im trying to make this app with by only studying udemy courses
and I took some java and C#, C, C++ in school
are you restricting yourself to just udemy courses or are you saying that's mainly what you're following?
im on winter break so I been studying udemy
here we recommend $helloworld
it's from microsoft who created and maintain C# and .NET, so it's your best bet
I've said it a lot of times before, paid courses are a scam. Youtube has the same quality as udemy courses
Learn by doing while simultaneously read docs and/or forums
I do like udemy though better than other sites and youtube videos
not better than microsoft learn
ok I will save those 2 links
Remember, C# uses PascalCase for methods so
check
becomes Check
and subtractFromList
becomes SubtractFromList
and you should be using properties instead of fields for the name, website, etc.
yeah Im kinda new to hands on experience
this is my 3rd or so project
plenty to learn
whats the difference between field and properties?
i looked it up
under the hood, a property is a field and a method to get and set that field
so you can, for instance, have a property with a public getter but a private setter
so the property can only be changed from within the class, but can be read from outside the class
$getsetdevolve
can be shortened to
can be shortened to
can be shortened to
can be shortened to
where would I be without you all
if a property is private, how do I retrieve the value for it?
private string name { get; } = name;
besides making it public
you don't, outside of the class
do I have to create a GetName function or is there an easier way?
the getter and setter are how the property is accessed
if you want it to be accessible outside the class, make them public
okay