C
C#Shell-Caster

✅ How do I reference a specific private instance of a class

I would like to know how I could reference a specific instance of a class, if the class is private and I'm in a different class
A
Angius15d ago
Are both in the same project?
S
Shell-Caster15d ago
no
A
Angius15d ago
If so, then just... do private classes are private to the assembly, project Still available anywhere else in the project Unless the class is nested
S
Shell-Caster15d ago
I know of some ways to get access to it if its not private but I can't seem to get it with reflection
A
Angius15d ago
No need to use reflection A private class can just be used It's private to the project So available anywhere within the project
S
Shell-Caster15d ago
I edited the message, Its a different project for context I am making a mod Is there a way to do it with reflection?
A
Angius15d ago
You would have to go through the assembly
S
Shell-Caster15d ago
what do you mean by go through the asssembly?
A
Angius15d ago
typeof(SomePublicClass).Assembly IIRC This will contain data of the project that contains that public class
S
Shell-Caster15d ago
the class is public but the instance is private and I already have access to the class
A
Angius15d ago
Well, is the instance stored in a field? Property?
S
Shell-Caster15d ago
Classname previousPlayerHeldBy;
A
Angius15d ago
So a field
S
Shell-Caster15d ago
yes
A
Angius15d ago
Should be as simple as googling "c# get private field reflections" then
S
Shell-Caster15d ago
I have googled for hours
A
Angius15d ago
You're either lying or you're not googling well https://www.c-sharpcorner.com/blogs/setting-and-getting-private-variable-of-a-class-without-properties Second result under the very search query I mentioned
S
Shell-Caster15d ago
I'm just bad at googling I guess thank you for the help
Want results from more Discord servers?
Add your server
More Posts
Receiving Game Controller Input while Minimized (WinForms C#)Pretty general question here. How would I go about receiving input from my user while they aren't tprocess startIve been trying to figure out why the proccess.start() hasnt been working✅ Configurations say that appsettings is returning nullBasically, i have a configuration and i'm trying to access a value from my appsettings, and all that✅ ASP.NET Core Web Api + SignalRHi, I have an API deployed on IIS but when a person wants to access it they get an error: "ERR_CONNE✅ .NET sdk not workingSo, I've installed the .NET sdk and did what I was told, but it's still not being detected by vscodeMEF No exports were found that match the constraintHi, i'm trying to implement MEF in my WPF app, however i'm getting this error, not sure why anymore.✅ WPF - set UIElement (image) in XAML depending on databound Property Enum valueI am trying to dynamically change a StatusBar image via a view's XAML depending upon a databound VieASP.NET Controller API + Blazor Client UI resources and helpHello! I'm doing a side project where I created the backend API with simple CRUD functionality and A✅ Run PuppeteerSharp in Docker ContainerI have an endpoint that creates PDFs using PuppeteerSharp. I work fine locally because it can automaDocker + Blazor + MSSQL handshake errorWhen I run dotnet ef database update I get the following error : ``Microsoft.Data.SqlClient.SqlExceProblem with corner radius XAML propertyI use a border with these properties: ```<Border CornerRadius="3" Background="{StaticResource Edito✅ :white_check_mark: Dictionary<int, ...> lookup time seems a bit too slowI was profiling a program, and I saw this: ```cs 100 % HasObject • 136 ms • 189 217 Calls • Engine.Rhow to read .txt file next to the Program.csi have the following code that is begin run ```cs string fileContent = File.ReadAllText("hamlet.txt✅ Linker Error Trying to Build OpenSSL Static LinkingHello, I've been trying to compile and build OpenSSL to try and encrypt a text file using AES 256 buHow things get to the placeI have found this one thing by Microsoft that confused me so much ```cs public async Task<IActionResVisual code studio and msbuildim currently having problems while scripting apparently when i press (Run Build Task) im getting thiMediatR - System.Text.Json.JsonException: 'S' is an invalid start of a value.I have a project with Clean Architecture and MediatR. My API gets the request fine and the command Blazor, auto unsubscribe patternI have created website using blazor, and if some component subscribe to something then it implement ✅ Form1.resx file gives error on Internet or Restricted zoneForm1.resx file gives error on Internet or Restricted zone I can't fix it error (english):Severity LHelp with API structureI want to create modular API structure https://timdeschryver.dev/blog/maybe-its-time-to-rethink-our-