Atomic data type in C# RRS feed

  • Question

  • Hello,

    What does atomic data type in C#?


    Sunday, March 8, 2020 4:13 PM

All replies

  • Perhaps code samples mixed with a narrative will help


    Please remember to mark the replies as answers if they help and unmarked them if they provide no help, this will help others who are looking for solutions to the same or similar problem. Contact via my Twitter (Karen Payne) or Facebook (Karen Payne) via my MSDN profile but will not answer coding question on either.

    NuGet BaseConnectionLibrary for database connections.

    profile for Karen Payne on Stack Exchange

    Sunday, March 8, 2020 4:22 PM
  • For a type to be "atomic" it just needs to be irreducible, independent, standalone, inherits from nothing else and is inherited by nothing else, and requires nothing but its own internal code to do its job.

    To say that you shouldn't overload operators unless you're building atomic data types is retarded.  Any object or type at all should be able to equivalate (and unequivalate) itself to other instances of the same type and sometimes other instances of other types. 

    A good example is Int64 vs Int32 (or long vs int if you prefer).  These are both atomic types, relying on nothing and nothing relying on them, but since the Int64 can represent the exact same range (plus a lot more) as the Int32 it's stupid for any language specification not to require that the types should be directly comparable for equality and inequality and greater/less-than without typecasting.

    What book or website is your quoted/underlined passage from?

    Before you can learn anything new you have to learn that there's stuff you don't know.

    Sunday, March 8, 2020 4:33 PM
  • Hi Arash_89,

    Thank you for posting here.

    Here are some posts on atomic variables and atoms.

    Some of them are c, but the definition of "atoms" is similar, so I think it may help you understand this problem.

    Are primitive data types in c# atomic (thread safe)?

    What operations on a c++ 11 atomic variable are actually atomic?

    What exactly is std::atomic?

    Best Regards,


    MSDN Community Support
    Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.

    Monday, March 9, 2020 3:55 AM