c What is the difference between a method of a String class and a method of a string object ?

Updated on technology 2024-04-15
12 answers
  1. Anonymous users2024-02-07

    For example, declaring a: string str1;

    There are many ways to do this on the str1 object;

    There are also many methods for the string class;

    There are ways to do both.

    string method: is a static method defined by the static keyword, which is called with the class name.

    Methods for string objects: are non-static methods that are to be called with an instance of a class (i.e., an object).

    For example, tolower is a non-static method, and format is a static method, but both methods are members of the string class:

    string str1="tom";

    Non-static methods (called with objects).

    hello ","tom");Static methods (called with class names) can select the string class and go to the definition to see:

  2. Anonymous users2024-02-06

    str1 is not a subclass, it is an instance of string.

    "string method" is a static method on a string class; "Methods for string objects" are non-static methods on string that must be used on instance, i.e. str1.

    e.g., null); There is no need for a specific instance reference, both are null, here is the "string method".

    Here equals is the instance method, and str1 is not allowed to be null, which is the "method of string objects".

  3. Anonymous users2024-02-05

    The most intuitive difference is that the string object contains a lot of encapsulated methods, which will be much easier to operate.

    The operation of strings requires you to call library functions or write your own.

    I think I heard this Yang clearly, I don't know if you understand?

  4. Anonymous users2024-02-04

    is a class in c, and string is. .NET Framework classes.

    The string is mapped to. String3 for .NET FrameworkIf you use string, the compiler will compile it into string, so if you use string directly, you can make the compiler do a little less work, if you use c, it is recommended to use string, which is more in line with the specification.

    Always represents or string only if there is a using system and there is no type named string (class, struct, delegate, enum) in the current namespace.

    is a keyword, string is not, that is, string cannot be used as a name for a class, struct, enumeration, field, variable, method, property, whereas string can.

  5. Anonymous users2024-02-03

    string is a string class.

    string is an alias for , which is equivalent to it.

  6. Anonymous users2024-02-02

    A class is a collection of objects with the same data structure (static features) and the same operations (dynamic behavior features), which is an abstraction of the same class of things, and the definition of a class includes a set of data attributes and a set of legitimate operations on the data. For example, if you don't have the int type defined in c, you have to define it yourself, such as the student class.

    The object is a specific entity, such as a student in the class of students, such as Zhang San, and other methods are specific things to do, such as students to eat, sleep, play ball, and such things.

    An attribute is a student that has some similarities such as their name, gender, height, etc., which can be obtained by setting its get vs. set methods.

    A field is similar to a property, when only it is defined and used in a method, it is set as a get and set as a field.

    Functions include methods, properties, fields, and a host of other things that operate on objects.

  7. Anonymous users2024-02-01

    Exactly the same, no difference;

    There is a difference between string and string (capitalization).

    The string type represents a sequence of characters (zero or more Unicode characters). string is .An alias for string in the .NET Framework.

    Although string is a reference type, the equality operators ( == and !) are defined as equal operators=) is to compare the value of a string object (not a reference). This makes testing for string equality more intuitive.

    string represents text, which is a series of Unicode characters; namespace: system ; assembly: mscorlib (in ); A string object is called immutable (read-only) because once the object is created, the value of the object cannot be modified.

    It may seem that a method that modifies a string object actually returns a new string object with the modified contents. If you need to modify the actual content of a string object, use .StringBuilder class.

    For details, please refer to the detailed help content in C

  8. Anonymous users2024-01-31

    string and string?

    Same. Lowercase string is for convenience.

    string s is equivalent to string s = new string();

  9. Anonymous users2024-01-30

    Actually, there is basically no difference. If you look up MSDN, you'll see it clearly.

  10. Anonymous users2024-01-29

    The first floor is already very clear, just take his answer.

  11. Anonymous users2024-01-28

    It's a cliché.

    String is a class, and string is a data type.

    string is the class in c, string is. .NET Framework's classes (which don't show blue in the CIDE).

    c string is mapped to. String for .NET Framework

    If you use string, the compiler will compile it to string, so if you use string directly, you can make the compiler do a little less work.

    If C is used, it is recommended to use string, which is more in line with the specification.

    string always stands for or , string is only preceded by using system; and when there is no type named string (class, struct, delegate, enum) in the current namespace.

    string is a keyword, string is not, that is, string cannot be used as a name for a class, struct, enumeration, field, variable, method, property, while string can.

  12. Anonymous users2024-01-27

    string is the class in c, string is. .NET Framework's classes (which don't show blue in the C IDE) c string maps to. .NET Framework's string If you use a string, the compiler will compile it to a string, so if you use string directly, you can make the compiler do a little less work.

    If you use c, it is recommended to use string, which is more in line with the specification string always represents or , and string is only preceded by using system; and there is no type named string in the current namespace (class, struct, delegate, enum) to mean that string is a keyword, string is not, that is, string cannot be used as a name for a class, struct, enumeration, field, variable, method, property, while string can.

    string is the type name (and keyword) of the CLR, and string is the keyword in C. String will be converted to String by default when compiled, and a few more lines of converted ** will be added here. A lot of times it's recommended to use the CLR type over the C type (that's the advice of the experts).

    For example, it is better to use int32 when using int, etc. A lot of times it's a matter of habit, a matter of norms.

    Another difference is that the colors are different in VS: string is green, string is blue.

Related questions
3 answers2024-04-15

The file class is used for typical operations such as copying, moving, renaming, creating, opening, deleting, and appending to files. You can also use the file class to get and set file properties or datetime information about file creation, access, and write operations. >>>More

7 answers2024-04-15

Do it by your train of thought.

Method 1. string strnumber="200m"; >>>More

20 answers2024-04-15

First, the mode is different.

Class A** is to directly deduct the subscription fee when subscribing, which is usually a "front-end charge" model. The front-end charging model is the most commonly used charging mode for current investors, and the over-the-counter charging mode that we usually subscribe to is generally the front-end charging model. >>>More

19 answers2024-04-15

Write in the click of button1; Then write using system in the main function; >>>More

20 answers2024-04-15

It mainly depends on the acceleration and rapid steering of these 3 points. >>>More