C
C#2y ago
JJ

❔ how to use List that have struct type ( WPF)

public struct Linq { public Window win; public TextBox textBox; } private void newWindow() { Window win = new Window(); TextBlock t = new TextBlock() List<Linq> a = new List<Linq>(); a.Add(win, t); } I wanna input struct Linq (TextBlock and Window class object) to List
14 Replies
ero
ero2y ago
is there something that's not working with this code? oh, right do you know how to instantiate objects?
JJ
JJOP2y ago
yea I wanna know how to use list included type struct
ero
ero2y ago
just like any other type structs aren't special in this
JJ
JJOP2y ago
oh actually Im cpp user so ,I just used it
ero
ero2y ago
you need to new the struct up a.Add(new Linq { win = win }); or whatever you feel like
JJ
JJOP2y ago
is it wrong? public struct Linq { public Window win; public TextBox textBox; }
ero
ero2y ago
no, the struct is fine (but it shouldn't really be a struct)
JJ
JJOP2y ago
it is alright but Could not use pair like this a.Add(new Linq { win = win, textBox = t });
ero
ero2y ago
look at your errors
JJ
JJOP2y ago
ero
ero2y ago
and what do you think that could mean
JJ
JJOP2y ago
ah resolve ! thanks I missed type ( textBox, textBlock)
JJ
JJOP2y ago
Accord
Accord2y ago
Was this issue resolved? If so, run /close - otherwise I will mark this as stale and this post will be archived until there is new activity.
Want results from more Discord servers?
Add your server