I recently stumbled across the unexpected behavior of C# when dealing with static variables. I put it a green unit test:
private static string a = $"a{b}";
private static string b = $"b{2+100}";
private static string c = $"{b}c";
[Test]
public void Test()
{
Assert.AreEqual("a",a);
Assert.AreEqual("b102c", c);
Assert.AreEqual(10, ReturnSum()(2,3));
}
As C# has an ECMA definition, this behavior is described in there (reference found here):
17.11: The execution of a static constructor is triggered by the first of the following events to occur within an application domain:
- An instance of the class is created.
- Any of the static members of the class are referenced.
If a class contains the Main method (§10.1) in which execution begins, the static constructor for that class executes before the Main method is called. If a class contains any static fields with initializers, those initializers are executed in textual order immediately prior to executing the static constructor (§17.4.5).
Despite that, it is quite weird that the compiler doesn’t warn you if a static member is referencing a static member which is executed later.
274 comments
**nitric boost**
nitric boost is a dietary formula crafted to enhance vitality and promote overall well-being.
https://t.me/Official_1xbet_1xbet/1837
https://t.me/Official_1xbet_1xbet/1659
https://t.me/Official_1xbet_1xbet/1672
**sleeplean**
sleeplean is a US-trusted, naturally focused nighttime support formula that helps your body burn fat while you rest.
https://t.me/s/Official_1xbet_1xbet/1763
**wildgut**
wildgutis a precision-crafted nutritional blend designed to nurture your dog’s digestive tract.
https://t.me/s/Official_1xbet_1xbet/1595
https://t.me/s/Official_1xbet_1xbet/1677
https://t.me/Official_1xbet_1xbet/1639
https://t.me/s/Official_1xbet_1xbet/1819
https://t.me/Official_1xbet_1xbet/1693
**mitolyn**
mitolyn a nature-inspired supplement crafted to elevate metabolic activity and support sustainable weight management.
https://t.me/s/Official_1xbet_1xbet/1742
https://t.me/Official_1xbet_1xbet/1623
**yusleep**
yusleep is a gentle, nano-enhanced nightly blend designed to help you drift off quickly, stay asleep longer, and wake feeling clear.
**zencortex**
zencortex contains only the natural ingredients that are effective in supporting incredible hearing naturally.
https://t.me/Official_1xbet_1xbet/1674
https://t.me/s/Official_1xbet_1xbet/1657
https://t.me/Official_1xbet_1xbet/1626
https://t.me/Official_1xbet_1xbet/1716
https://t.me/Official_1xbet_1xbet/1730
https://t.me/s/Official_1xbet_1xbet/1746
**breathe**
breathe is a plant-powered tincture crafted to promote lung performance and enhance your breathing quality.
https://t.me/s/Official_1xbet_1xbet/1732
https://t.me/Official_1xbet_1xbet/1663
https://t.me/Official_1xbet_1xbet/1601
https://t.me/Official_1xbet_1xbet/1728
https://t.me/Official_1xbet_1xbet/1832
https://t.me/s/Official_1xbet_1xbet/1775
**prostadine**
prostadine is a next-generation prostate support formula designed to help maintain, restore, and enhance optimal male prostate performance.
https://t.me/Official_1xbet_1xbet/1706
https://t.me/Official_1xbet_1xbet/1835
https://t.me/Official_1xbet_1xbet/1855
https://t.me/s/Official_1xbet_1xbet/1710
https://t.me/Official_1xbet_1xbet/1757
https://t.me/s/Official_1xbet_1xbet/1858
https://t.me/s/Official_1xbet_1xbet/1601
https://t.me/Official_1xbet_1xbet/1619
https://t.me/Official_1xbet_1xbet/1705
https://t.me/Official_1xbet_1xbet/1815
https://t.me/Official_1xbet_1xbet/1838
https://t.me/Official_1xbet_1xbet/1836
https://t.me/Official_1xbet_1xbet/1778
https://t.me/s/Official_1xbet_1xbet/1661
https://t.me/s/Official_1xbet_1xbet/1671
https://t.me/s/Official_1xbet_1xbet/1844
https://t.me/s/Official_1xbet_1xbet/1745
https://t.me/s/Official_1xbet_1xbet/1619
https://t.me/s/Official_1xbet_1xbet/1735