Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 556359
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T11:54:40+00:00 2026-05-13T11:54:40+00:00

A few days ago, I decided to start learning C#. So, I got a

  • 0

A few days ago, I decided to start learning C#. So, I got a book and started reading and practicing with code. I was surprised when I saw that string in C# is considered a primitive type.

But I was more surprised when I saw that string, as well as all the other primitive types in C# have methods. I’m a Java developer and my understanding was that primitive data types don’t have methods, only classes have. But in C#, the following is valid:

string name = "alex";
Console.WriteLine(name.ToUpper());

How is this possible? Are they really primitives? What am I missing here?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-13T11:54:41+00:00Added an answer on May 13, 2026 at 11:54 am

    string is not a primitive type in C#. It’s one of two predefined (i.e., part of the language specification) reference types in C# (the other being object). The primitive types in C# are Boolean (bool), Byte (byte), SByte (sbyte), Int16 (short), UInt16, Int32 (int), UInt32 (uint), Int64 (long), UInt64 (ulong), IntPtr, UIntPtr, Char (char), Double (double), and Single (single).
    Note that the specification states "it is also possible to use structs and operator
    overloading to implement new “primitive” types in the C# language" but that typeof(MyStruct).IsPrimitive is false if MyStruct is a user-defined struct.

    I got a book and started reading and practicing with code. I was surprised when I saw that string in C# is considered a primitive type.

    The book said this? Which book?

    I’m a Java developer and my understanding was that primitive data types don’t have operations, only classes have.

    Plainly and simply, C# and Java are different languages. In C# there is the notion of object from which almost everything derives (yes, there are exceptions the most important of which is interfaces). From object there is a derived type called ValueType. Derivatives of ValueType are structs which have value semantics. All other derivatives of object are reference types. All of these objects encapsulate data and behavior (i.e., they can have methods).

    string name = "alex";

    Console.WriteLine(name.ToUpper());

    How is this possible?

    I don’t understand your confusion with this code snippet. name is an instance of string that is definitely assigned by the string literal "alex" and we are invoking one of the overloads of the method String.ToUpper on name. Then the overload of Console.WriteLine that accepts an instance of string is invoked. You can even do this

    Console.WriteLine("alex".ToUpper());
    

    Are they really primitives?

    No. string is not a primitive.

    What am I missing here?

    That C# and Java are related but very different programming languages.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I’ve started learning Erlang a few days ago and it’s definitely a very interesting
I started learning Rails only a few days ago, but in the mean time
I've started learning rails3 few days ago, and since today, every time I run
got a new blog at wordpress few days ago ( http://ghads.wordpress.com ) and I
So far I have worked in the console and a few days ago decided
I have decided to learn (Common) Lisp a few days ago and I realize
I started using Raphael.js a few days ago and I'm really enjoying it. The
I started using django framework just a few days ago and i desperately need
I started multithread programming in C# (WPF) few days ago and here is a
I started programming in Lua few days ago. I have become familiar with the

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.