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.
549 comments
https://t.me/s/Official_1xbet1/1404
https://t.me/s/Official_1xbet1/1417
https://t.me/Official_1xbet1/110
https://t.me/Official_1xbet1/1027
https://t.me/s/Official_1xbet1/1274
https://t.me/Topcasino_licenziya/30
https://t.me/s/Topcasino_licenziya/32
https://t.me/s/kazino_s_licenziei/2
https://t.me/Topcasino_licenziya/6
https://t.me/Topcasino_licenziya/26
https://t.me/s/Topcasino_licenziya/39
https://t.me/s/top_online_kazino/6
https://t.me/s/top_online_kazino/4
https://t.me/s/top_online_kazino/8
https://t.me/s/reyting_luchshikh_kazino
https://t.me/top_online_kazino/6
https://t.me/top_online_kazino/5
https://t.me/top_online_kazino/9
https://t.me/s/top_online_kazino/10
https://cse.google.co.ve/url?sa=t&url=https://t.me/Official_1xbet_1xbet/1291
https://cse.google.ee/url?sa=t&url=https://t.me/Official_1xbet_1xbet/1245
http://lifewealthadvisor.com/__media__/js/netsoltrademark.php?d=https://t.me/Official_1xbet_1xbet/1652
https://www.avito.ru/surgut/predlozheniya_uslug/apparatnyy_manikyur_i_pedikyur_s_pokrytiem_4030660549?utm_campaign=native&utm_medium=item_page_ios&utm_source=soc_sharing_seller
http://archityke.com/__media__/js/netsoltrademark.php?d=https://t.me/s/Official_1xbet_1xbet/980
http://ip50.ofac.com/__media__/js/netsoltrademark.php?d=https://t.me/s/Official_1xbet_1xbet/742
https://t.me/s/om_1xbet/11
https://t.me/top_casino_rating_ru/9
https://t.me/om_1xbet/7
https://t.me/top_casino_rating_ru/14
https://t.me/s/om_1xbet/10
https://t.me/om_1xbet/11
https://t.me/s/om_1xbet/9
https://t.me/top_casino_rating_ru/7
https://t.me/top_casino_rating_ru/10
https://t.me/s/om_1xbet/7
https://t.me/s/om_1xbet/15
https://t.me/om_1xbet/15
https://t.me/of_1xbet/313
Регистрируйтесь прямо сейчас на 1win, чтобы активировать 1win ваучер сайт и получать до 100% бонуса за первый депозит! В онлайн-казино вас ждут свежие слоты и фриспины, ставки на спорт с высокими коэффициентами и лайв-ставки, а также быстрый вывод выигрышей и кэшбэк до 15%. Наслаждайтесь простотой входа, минимальным депозитом от 10 рублей и круглосуточным доступом для реальных побед и выгодных предложений!
1win зеркало сайта актуальное — заходи прямо сейчас и открывай для себя крупнейшее онлайн-казино и букмекерскую платформу с высокими коэффициентами и мгновенным выводом выигрышей! Получи бонус за депозит до 5000 ?, фриспины в слотах, ставки на спорт с лайв-режимом, кэшбэк до 10%, а также быстрый доступ к личному кабинету круглосуточно. Минимальный депозит — всего 100 ?, обеспечивая легкий старт и возможность быстро увеличивать свой выигрыш!
1 win что это — начни выигрывать прямо сейчас! В 1win доступны лучшие онлайн казино с слотами и фриспинами, ставки на спорт с высокими коэффициентами и лайв-ставки в реальном времени. Получай бонусы за депозит до 10 000 ?, используй промокод для фриспинов и кэшбэк до 15%, а быстрая регистрация и минимальный депозит от 100 ? позволяют вывести выигрыш в пару кликов — круглосуточный доступ и быстрые выплаты делают игру максимально выгодной и доступной!
https://t.me/s/ef_beef
https://t.me/s/Official_Ru_1WIN
https://telegra.ph/Beef-kazino-11-25
https://t.me/s/officials_pokerdom/3621
https://t.me/Martin_officials
Yo, slots2345game is my jam! Been hitting it up after work and sometimes the afteroon, you know. Solid selection, no lag. Check it out! slots2345game
https://t.me/s/Beefcasino_officials
https://t.me/s/Martin_casino_officials