সি # এর const
জাভা হিসাবে ঠিক একই জিনিস final
, একেবারে সর্বদা ব্যতীত static
। আমার মতে, ভেরিয়েবলের অ- ব্যবহারযোগ্য const
হওয়ার জন্য এটি সত্যিই প্রয়োজনীয় নয় static
, তবে আপনাকে যদি অবিচ্ছিন্নভাবে const
চলকটি অ্যাক্সেস static
করতে হয় তবে আপনি এটি করতে পারেন:
class MyClass
{
private const int myLowercase_Private_Const_Int = 0;
public const int MyUppercase_Public_Const_Int = 0;
/*
You can have the `private const int` lowercase
and the `public int` Uppercase:
*/
public int MyLowercase_Private_Const_Int
{
get
{
return MyClass.myLowercase_Private_Const_Int;
}
}
/*
Or you can have the `public const int` uppercase
and the `public int` slighly altered
(i.e. an underscore preceding the name):
*/
public int _MyUppercase_Public_Const_Int
{
get
{
return MyClass.MyUppercase_Public_Const_Int;
}
}
/*
Or you can have the `public const int` uppercase
and get the `public int` with a 'Get' method:
*/
public int Get_MyUppercase_Public_Const_Int()
{
return MyClass.MyUppercase_Public_Const_Int;
}
}
ঠিক আছে, আমি এখন বুঝতে পারি যে এই প্রশ্নটি 4 বছর আগে জিজ্ঞাসা করা হয়েছিল, তবে যেহেতু আমি প্রায় 2 ঘন্টা কাজ রেখেছি, উত্তর এবং কোড ফর্ম্যাটিংয়ের বিভিন্ন ধরণের চেষ্টা করে এই উত্তরটি পেয়েছি, আমি এখনও পোস্ট করছি। :)
তবে, রেকর্ডটির জন্য, আমি এখনও মূর্খতা বোধ করছি।