Click here to Skip to main content
14,876,938 members
Home / Discussions / C#
   

C#

 
GeneralRe: How to preserve DataGridView row and text color when using column filters? Pin
Alex Dunlop21-Apr-21 16:53
MemberAlex Dunlop21-Apr-21 16:53 
GeneralRe: How to preserve DataGridView row and text color when using column filters? Pin
Dave Kreskowiak21-Apr-21 17:27
mveDave Kreskowiak21-Apr-21 17:27 
Questionrecord list access Pin
Member 1509020319-Apr-21 12:16
MemberMember 1509020319-Apr-21 12:16 
AnswerRe: record list access Pin
Dave Kreskowiak19-Apr-21 17:51
mveDave Kreskowiak19-Apr-21 17:51 
GeneralRe: record list access Pin
Member 1509020319-Apr-21 19:43
MemberMember 1509020319-Apr-21 19:43 
GeneralRe: record list access Pin
Pete O'Hanlon20-Apr-21 20:55
mvePete O'Hanlon20-Apr-21 20:55 
Questionc# How to access data in an other object Pin
Member 1509020319-Apr-21 2:29
MemberMember 1509020319-Apr-21 2:29 
AnswerRe: c# How to access data in an other object Pin
OriginalGriff19-Apr-21 2:58
mveOriginalGriff19-Apr-21 2:58 
adatlista is not a variable, it's a class:
C#
class adatlista
    {
        public List<adatok> lista = new List<adatok>();
    }

So you can't access it's list like this:
C#
adatlista.lista.Add(new adatok());

Why not?
Because you need an instance of the class to work with ...

Let's ignore computers for a moment, and talk about cars.
We both have a car: the same make, the same model, the same colour, the same engine, the same age.
I give you a ride to the shops, and while in my car, you put your mobile phone in the glove box.

When you get home again, you need you mobile so you go to your car and open the glove box. Is your phone there?

No, of course not - it's in the glove box in my car. You know that it can only be accessed my opening my car, opening that glove box and reaching in for your phone, because you know that the two vehicles are separate instances of the particular class of black Mercedes A-class cars that they made in 2006.
You know that despite being outwardly identical, they are very different vehicles and that to do anything with them, you have to use the right instance. You want to drive to the airport, you take your car, not mine!

Classes and instances also matter in computers: Car is a class, but "your car" is a Car type variable which holds a Car class instance, "my car" is another Car type variable which holds a different Car class instance.

So you access the List in your adatlista class, you need to create an use a specific instance of that class:
C#
adatlista adat = new adatlista();
adat.lista.Add(new adatok());


There is a way to get what you wrote to work, but ... it's probably something you haven't really covered yet: static classes - so I won't go into that. It's pretty important that you understand instances anyway!

Does that make sense?
"I have no idea what I did, but I'm taking full credit for it." - ThisOldTony
"Common sense is so rare these days, it should be classified as a super power" - Random T-shirt
AntiTwitter: @DalekDave is now a follower!

Question.net passive mvp implementation w unity novice questions Pin
Romar Nicholas Mandap18-Apr-21 15:26
MemberRomar Nicholas Mandap18-Apr-21 15:26 
QuestionRecordlist in object blocked by error Pin
Member 1509020318-Apr-21 10:57
MemberMember 1509020318-Apr-21 10:57 
AnswerRe: Recordlist in object blocked by error Pin
Mycroft Holmes18-Apr-21 11:25
professionalMycroft Holmes18-Apr-21 11:25 
AnswerRe: Recordlist in object blocked by error Pin
Dave Kreskowiak18-Apr-21 11:34
mveDave Kreskowiak18-Apr-21 11:34 
AnswerRe: Recordlist in object blocked by error Pin
James Curran20-Apr-21 3:37
MemberJames Curran20-Apr-21 3:37 
QuestionWhy BeginGetContext of HTTPListener within Window's Service didn't react or trigger? Pin
razzqc16-Apr-21 5:19
Memberrazzqc16-Apr-21 5:19 
AnswerRe: Why BeginGetContext of HTTPListener within Window's Service didn't react or trigger? Pin
Gerry Schmitz16-Apr-21 8:37
mveGerry Schmitz16-Apr-21 8:37 
GeneralRe: Why BeginGetContext of HTTPListener within Window's Service didn't react or trigger? Pin
razzqc16-Apr-21 10:06
Memberrazzqc16-Apr-21 10:06 
QuestionWhy GC.Collect() call twice required when use GC.WaitForPendingFinalizers() Pin
Mou_kol10-Apr-21 22:06
MemberMou_kol10-Apr-21 22:06 
AnswerRe: Why GC.Collect() call twice required when use GC.WaitForPendingFinalizers() Pin
OriginalGriff10-Apr-21 22:48
mveOriginalGriff10-Apr-21 22:48 
QuestionC# Unable to update data table values Pin
Mou_kol10-Apr-21 1:34
MemberMou_kol10-Apr-21 1:34 
AnswerRe: C# Unable to update data table values Pin
OriginalGriff10-Apr-21 2:13
mveOriginalGriff10-Apr-21 2:13 
GeneralRe: C# Unable to update data table values Pin
Mou_kol10-Apr-21 3:04
MemberMou_kol10-Apr-21 3:04 
GeneralRe: C# Unable to update data table values Pin
Dave Kreskowiak10-Apr-21 4:23
mveDave Kreskowiak10-Apr-21 4:23 
GeneralRe: C# Unable to update data table values Pin
OriginalGriff10-Apr-21 7:57
mveOriginalGriff10-Apr-21 7:57 
GeneralRe: C# Unable to update data table values Pin
OriginalGriff10-Apr-21 8:00
mveOriginalGriff10-Apr-21 8:00 
GeneralRe: C# Unable to update data table values Pin
Richard MacCutchan10-Apr-21 21:07
mveRichard MacCutchan10-Apr-21 21:07 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.