File tree Expand file tree Collapse file tree 3 files changed +32
-0
lines changed
content/blog/interview/questionsetsdumps Expand file tree Collapse file tree 3 files changed +32
-0
lines changed Original file line number Diff line number Diff line change @@ -1598,9 +1598,41 @@ public class Logger
15981598 {
15991599 LogFilePath = " logfile.txt" ;
16001600 }
1601+ public static void Log (string message )
1602+ {
1603+ Console .WriteLine (" Logging message: " + message );
1604+ }
16011605}
16021606```
16031607
1608+ ### Live Preview of static Constructor
1609+
1610+ ![ images] ( ./constructorStatic.gif )
1611+
1612+ > Code For Staic Class with Static Constructor
1613+
1614+ ``` csharp
1615+ public static class Logger
1616+ {
1617+ public static string LogFilePath ;
1618+
1619+ // Static constructor
1620+ static Logger ()
1621+ {
1622+ LogFilePath = " logfile.txt" ;
1623+ Console .WriteLine (" Logger static constructor" );
1624+ }
1625+ public static void Log (string message )
1626+ {
1627+ Console .WriteLine (" Logging message: " + message );
1628+ }
1629+ }
1630+ ```
1631+
1632+ ### Live Preview of static Constructor and static class
1633+
1634+ ![ images] ( ./staticClass.gif )
1635+
16041636### Q70. Can we have parameters or access modifiers in static constructor?
16051637
16061638- ** Parameters:** No, static constructors cannot have parameters.
You can’t perform that action at this time.
0 commit comments