tagged [private]

assign value of readonly variable in private method called only by constructors

assign value of readonly variable in private method called only by constructors C# compiler gave me the following error CS0191: A readonly field cannot be assigned to (except in a constructor or a var...

27 Jul at 17:38

How to Export Private / Secret ASC Key to Decrypt GPG Files

How to Export Private / Secret ASC Key to Decrypt GPG Files Background: My boss has tried exporting an ASC key to me with public and private parts but whenever I get the file the private part never lo...

8 Nov at 05:39

How does a public key verify a signature?

How does a public key verify a signature? I am trying to get a better grapple on how public/private keys work. I understand that a sender may add a digital signature to a document using his/her privat...

Defining private module functions in python

Defining private module functions in python According to [http://www.faqs.org/docs/diveintopython/fileinfo_private.html](http://www.faqs.org/docs/diveintopython/fileinfo_private.html): > Like most lan...

20 Jun at 09:12

How do I use reflection to invoke a private method?

How do I use reflection to invoke a private method? There are a group of private methods in my class, and I need to call one dynamically based on an input value. Both the invoking code and the target ...

12 Dec at 14:18

Why should I use a private variable in a property accessor?

Why should I use a private variable in a property accessor? Sorry If I am being noob, I have this doubt, why do we use private variables and set them using properties ? Why can't we just use properite...

private TestInitialize method is not initializing objects

private TestInitialize method is not initializing objects I have a test class that should basically be like the following: ``` [TestClass] public class MyTest { private MyClass o1; private MyClass...

Private method naming convention

Private method naming convention Is there a convention for naming the private method that I have called "`_Add`" here? I am not a fan of the leading underscore but it is what one of my teammates sugge...

8 Sep at 23:4

What is the use of a private static variable in Java?

What is the use of a private static variable in Java? If a variable is declared as `public static varName;`, then I can access it from anywhere as `ClassName.varName`. I am also aware that static memb...

9 Jun at 22:29

CngKey.Import on azure

CngKey.Import on azure I use this code to extract key, from embedded `base64` string. It works fine when I test it locally but when I publish on azure I get following exception: (onc

16 Dec at 18:55

Web.config for authorization of a private user folder

Web.config for authorization of a private user folder I have a private folder with thousand of users' folders which only be accessible by the correct user. No user can access other users' folders. I c...

C# Set probing privatePath without app.config?

C# Set probing privatePath without app.config? I have a C# application, and to organize its files I have some DLL's in a folder called "Data". I want the EXE to check this folder for the DLL's just li...

27 Apr at 05:31

Private 'set' in C# - having trouble wrapping my brain around it

Private 'set' in C# - having trouble wrapping my brain around it I've seen a lot of example code written using something like (please forgive how horribly canned this is): Unfortunately, these kinds o...

22 Jul at 20:45

Get Private Key from BouncyCastle X509 Certificate? C#

Get Private Key from BouncyCastle X509 Certificate? C# Normally when I grab an `X509Certificate2` out of my keystore I can call `.PrivateKey` to retrieve the cert's private key as an `AsymmetricAlgori...

Initialize private readonly fields after Deserializing

Initialize private readonly fields after Deserializing I need to initialize private readonly field after Deserialization. I have folowing DataContract: ``` [DataContract] public class Item { public ...

C# Make everything following public / private like in C++?

C# Make everything following public / private like in C++? I recently started learning C#, but I have some background in C++. I was wondering how I would do something like I tried doing this in C#, bu...

7 Sep at 05:18

C# Private members visibility

C# Private members visibility We have a Student class in our business model. something struck me as strange, if we are manipulating one student from another student, the students private members are v...

27 Aug at 13:13

Any reason to write the "private" keyword in C#?

Any reason to write the "private" keyword in C#? As far as I know, `private` is the default in C# (meaning that if I don't write `public`, `protected`, `internal`, etc. it will be `private` by default...

Call private method retaining call stack

Call private method retaining call stack I am trying to find a solution to 'break into non-public methods'. I just want to call `RuntimeMethodInfo.InternalGetCurrentMethod(...)`, passing my own parame...

9 Dec at 20:22

Using "OPENSSH" private key file in string with SSH.NET in C# fails with "invalid private key file"

Using "OPENSSH" private key file in string with SSH.NET in C# fails with "invalid private key file" I'm not experienced with SFTP or OpenSSH. I am trying to connect to a client's SFTP to upload a file...

15 Jan at 06:51

Why are private virtual methods illegal in C#?

Why are private virtual methods illegal in C#? Coming from a C++ background, this came as a surprise to me. In C++ it's good practice to make virtual functions private. From [http://www.gotw.ca/public...

3 Apr at 06:10

JUnit Testing private variables?

JUnit Testing private variables? I have been assigned the task of unit testing a class that I never worked directly on with JUnit, and am strictly forbidden to change the code in the package. This is ...

Forced Garbage collection or reflection to a Private field, which is less evil?

Forced Garbage collection or reflection to a Private field, which is less evil? We have a third party library that internally uses a SafeHandle to an unmanaged resource. In some error cases it is nece...

JavaScript private methods

JavaScript private methods To make a JavaScript class with a public method I'd do something like: That way users of my class can: ``` var restaurant = new Restaurant(); restaurant.buy_food(); restaura...

7 Jun at 19:54

Why are private fields private to the type, not the instance?

Why are private fields private to the type, not the instance? In C# (and many other languages) it's perfectly legitimate to access private fields of other instances of the same type. For example: As t...