C
C#•12mo ago
LordoToasty

CS0122, just with a partial class...

Hey there, my plan is to call a variable from another class(all necessary methods and classes are public), just that the class I want to call from is is a partial one, do I have to necessarily call from a normal kind of class(non-partial)?
11 Replies
Angius
Angius•12mo ago
A partial class is no different than a normal class It's just that its body can be split
LordoToasty
LordoToastyOP•12mo ago
I see, so what could be the problem then, shoul I send in the code?
Mayor McCheese
Mayor McCheese•12mo ago
There's some common use cases for partial classes, one is generated code; one part is autogenerated, and then you have the option of adding functionality to the class via another partial class file. This way you can safely regenerate the partial class without impacting your changes
Angius
Angius•12mo ago
I had to look up what CS0122 is It's "member inaccessible due to protection levels" And yeah, code would be useful
Mayor McCheese
Mayor McCheese•12mo ago
a guess is... public partial class A { } partial class A { }
LordoToasty
LordoToastyOP•12mo ago
not really, more like: public partial class A { int a = x } public class B { Console.Writeline(A.a) }
LordoToasty
LordoToastyOP•12mo ago
Angius
Angius•12mo ago
Well, if that is the case, then a is not public So Also, $paste the code here, and tell us which line the error occurs in
MODiX
MODiX•12mo ago
If your code is too long, you can post to https://paste.mod.gg/ and copy the link into chat for others to see your shared code!
LordoToasty
LordoToastyOP•12mo ago
yes yes ouu, I see it is private(its tagetport) it worked! 😅 Thank you both a lot, now I get it... ps: you got a dope profile picture anugis... (Love that anime)
Angius
Angius•12mo ago
Can't wait for the second season lol
Want results from more Discord servers?
Add your server