Click here to Skip to main content
15,896,453 members
Home / Discussions / C#
   

C#

 
GeneralRe: How to get a list of all drive letters including mapped network drives Pin
OriginalGriff13-Jan-15 5:06
mveOriginalGriff13-Jan-15 5:06 
GeneralRe: How to get a list of all drive letters including mapped network drives Pin
robwm113-Jan-15 8:25
robwm113-Jan-15 8:25 
GeneralRe: How to get a list of all drive letters including mapped network drives Pin
OriginalGriff13-Jan-15 8:37
mveOriginalGriff13-Jan-15 8:37 
QuestionHow to plot data into the graph which is receive from com port Pin
Member 1129798112-Jan-15 3:40
Member 1129798112-Jan-15 3:40 
AnswerRe: How to plot data into the graph which is receive from com port Pin
Afzaal Ahmad Zeeshan12-Jan-15 4:24
professionalAfzaal Ahmad Zeeshan12-Jan-15 4:24 
AnswerRe: How to plot data into the graph which is receive from com port Pin
V.12-Jan-15 21:12
professionalV.12-Jan-15 21:12 
QuestionStatic constructor? Pin
TMattC11-Jan-15 20:41
TMattC11-Jan-15 20:41 
AnswerRe: Static constructor? Pin
V.11-Jan-15 20:52
professionalV.11-Jan-15 20:52 
GeneralRe: Static constructor? Pin
TMattC11-Jan-15 21:07
TMattC11-Jan-15 21:07 
GeneralRe: Static constructor? Pin
V.11-Jan-15 21:17
professionalV.11-Jan-15 21:17 
GeneralRe: Static constructor? Pin
OriginalGriff11-Jan-15 21:18
mveOriginalGriff11-Jan-15 21:18 
GeneralRe: Static constructor? Pin
V.11-Jan-15 21:22
professionalV.11-Jan-15 21:22 
GeneralRe: Static constructor? Pin
OriginalGriff11-Jan-15 21:27
mveOriginalGriff11-Jan-15 21:27 
AnswerRe: Static constructor? Pin
OriginalGriff11-Jan-15 21:17
mveOriginalGriff11-Jan-15 21:17 
It's not impossible, but it is nasty. Very nasty!
As you say, you can't have a static constructor with a parameter - because static constructors are never called from your code directly, but by the system immediately prior to the first instance being created, so it can't call a parametrized one. So it has to be a parameter to an instance constructor: which means a check is needed:
C#
public abstract class Package
    {
    protected static int FUNC_LENGTH { get; private set; }
    private static bool onceAlready = false;
    public Package(int _funcLength)
        {
        if (!onceAlready)
            {
            FUNC_LENGTH = _funcLength;
            onceAlready = true;
            }
        }
    ...
    }

Bad command or file name. Bad, bad command! Sit! Stay! Staaaay...

AnswerRe: Static constructor? Pin
Dar Brett11-Jan-15 21:27
Dar Brett11-Jan-15 21:27 
GeneralRe: Static constructor? Pin
TMattC11-Jan-15 22:33
TMattC11-Jan-15 22:33 
GeneralRe: Static constructor? Pin
OriginalGriff11-Jan-15 22:58
mveOriginalGriff11-Jan-15 22:58 
GeneralRe: Static constructor? Pin
TMattC11-Jan-15 23:39
TMattC11-Jan-15 23:39 
GeneralRe: Static constructor? Pin
OriginalGriff11-Jan-15 23:46
mveOriginalGriff11-Jan-15 23:46 
GeneralRe: Static constructor? Pin
TMattC13-Jan-15 22:35
TMattC13-Jan-15 22:35 
GeneralRe: Static constructor? Pin
OriginalGriff13-Jan-15 23:04
mveOriginalGriff13-Jan-15 23:04 
GeneralRe: Static constructor? Pin
TMattC13-Jan-15 23:45
TMattC13-Jan-15 23:45 
AnswerRe: Static constructor? Pin
blachsmith16-Jan-15 15:36
blachsmith16-Jan-15 15:36 
QuestionStorm8 AutoHealer Pin
Sasz3r11-Jan-15 19:24
Sasz3r11-Jan-15 19:24 
AnswerRe: Storm8 AutoHealer Pin
OriginalGriff11-Jan-15 20:12
mveOriginalGriff11-Jan-15 20:12 

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.