读书人

C#中的string类内部源代码是哪?解决方

发布时间: 2011-12-27 22:22:54 作者: rapoo

C#中的string类内部源代码是哪?
C#中的string类源代码是哪?
在哪个文件夹下面?

我想看下这个类是怎么实现的。

[解决办法]
装一个Reflector工具看

[Serializable, ComVisible(true)]
public sealed class String : IComparable, ICloneable, IConvertible, IComparable <string> , IEnumerable <char> , IEnumerable, IEquatable <string>
{
// Fields
private const int alignConst = 3;
private const int charPtrAlignConst = 1;
public static readonly string Empty;
[NonSerialized]
private int m_arrayLength;
[NonSerialized]
private char m_firstChar;
[NonSerialized]
private int m_stringLength;
private const int TrimBoth = 2;
private const int TrimHead = 0;
private const int TrimTail = 1;
internal static readonly char[] WhitespaceChars;

// Methods
static String();
[MethodImpl(MethodImplOptions.InternalCall), CLSCompliant(false)]
public extern unsafe String(char* value);
[MethodImpl(MethodImplOptions.InternalCall), CLSCompliant(false)]
public extern unsafe String(sbyte* value);
[MethodImpl(MethodImplOptions.InternalCall)]
public extern String(char[] value);
[MethodImpl(MethodImplOptions.InternalCall)]
public extern String(char c, int count);
[MethodImpl(MethodImplOptions.InternalCall), CLSCompliant(false)]
public extern unsafe String(char* value, int startIndex, int length);
[MethodImpl(MethodImplOptions.InternalCall), CLSCompliant(false)]
public extern unsafe String(sbyte* value, int startIndex, int length);
[MethodImpl(MethodImplOptions.InternalCall)]
public extern String(char[] value, int startIndex, int length);
[MethodImpl(MethodImplOptions.InternalCall), CLSCompliant(false)]
public extern unsafe String(sbyte* value, int startIndex, int length, Encoding enc);
internal void AppendInPlace(char value, int currentLength);
internal void AppendInPlace(string value, int currentLength);
internal void AppendInPlace(char value, int repeatCount, int currentLength);
internal unsafe void AppendInPlace(char* value, int count, int currentLength);
internal void AppendInPlace(string value, int startIndex, int count, int currentLength);
internal void AppendInPlace(char[] value, int start, int count, int currentLength);
internal void ClearPostNullChar();
public object Clone();
public static int Compare(string strA, string strB);
public static int Compare(string strA, string strB, bool ignoreCase);
public static int Compare(string strA, string strB, StringComparison comparisonType);
public static int Compare(string strA, string strB, bool ignoreCase, CultureInfo culture);
public static int Compare(string strA, int indexA, string strB, int indexB, int length);
public static int Compare(string strA, int indexA, string strB, int indexB, int length, bool ignoreCase);
public static int Compare(string strA, int indexA, string strB, int indexB, int length, StringComparison comparisonType);
public static int Compare(string strA, int indexA, string strB, int indexB, int length, bool ignoreCase, CultureInfo culture);
public static int CompareOrdinal(string strA, string strB);
public static int CompareOrdinal(string strA, int indexA, string strB, int indexB, int length);
private static int CompareOrdinalHelper(string strA, string strB);
public int CompareTo(object value);
public int CompareTo(string strB);
public static string Concat(params object[] args);
public static string Concat(object arg0);
public static string Concat(params string[] values);


public static string Concat(object arg0, object arg1);
public static string Concat(string str0, string str1);
public static string Concat(object arg0, object arg1, object arg2);
public static string Concat(string str0, string str1, string str2);
[CLSCompliant(false)]
public static string Concat(object arg0, object arg1, object arg2, object arg3, __arglist);
public static string Concat(string str0, string str1, string str2, string str3);
private static string ConcatArray(string[] values, int totalLength);
public bool Contains(string value);
internal byte[] ConvertToAnsi_BestFit_Throw(int iMaxDBCSCharByteSize);
public static string Copy(string str);
public void CopyTo(int sourceIndex, char[] destination, int destinationIndex, int count);
private static unsafe string CreateString(sbyte* value, int startIndex, int length, Encoding enc);
internal static unsafe string CreateStringFromEncoding(byte* bytes, int byteLength, Encoding encoding);
private string CtorCharArray(char[] value);
private string CtorCharArrayStartLength(char[] value, int startIndex, int length);
private string CtorCharCount(char c, int count);
private unsafe string CtorCharPtr(char* ptr);
private unsafe string CtorCharPtrStartLength(char* ptr, int startIndex, int length);
internal bool EndsWith(char value);
public bool EndsWith(string value);
[ComVisible(false)]
public bool EndsWith(string value, StringComparison comparisonType);
public bool EndsWith(string value, bool ignoreCase, CultureInfo culture);
[ReliabilityContract(Consistency.WillNotCorruptState, Cer.MayFail)]
public override bool Equals(object obj);
[ReliabilityContract(Consistency.WillNotCorruptState, Cer.MayFail)]
public bool Equals(string value);
public static bool Equals(string a, string b);
public bool Equals(string value, StringComparison comparisonType);
public static bool Equals(string a, string b, StringComparison comparisonType);
[ReliabilityContract(Consistency.WillNotCorruptState, Cer.MayFail)]
private static bool EqualsHelper(string strA, string strB);
[MethodImpl(MethodImplOptions.InternalCall)]
private static extern string FastAllocateString(int length);
private static void FillStringChecked(string dest, int destPos, string src);
public static string Format(string format, params object[] args);
public static string Format(string format, object arg0);
public static string Format(IFormatProvider provider, string format, params object[] args);
public static string Format(string format, object arg0, object arg1);
public static string Format(string format, object arg0, object arg1, object arg2);
public CharEnumerator GetEnumerator();
[ReliabilityContract(Consistency.WillNotCorruptState, Cer.MayFail)]
public override int GetHashCode();
internal static string GetStringForStringBuilder(string value, int capacity);
internal static string GetStringForStringBuilder(string value, int startIndex, int length, int capacity);
public TypeCode GetTypeCode();
public int IndexOf(char value);
public int IndexOf(string value);
public int IndexOf(char value, int startIndex);
public int IndexOf(string value, int startIndex);
public int IndexOf(string value, StringComparison comparisonType);
[MethodImpl(MethodImplOptions.InternalCall)]
public extern int IndexOf(char value, int startIndex, int count);
public int IndexOf(string value, int startIndex, int count);
public int IndexOf(string value, int startIndex, StringComparison comparisonType);
public int IndexOf(string value, int startIndex, int count, StringComparison comparisonType);


public int IndexOfAny(char[] anyOf);
public int IndexOfAny(char[] anyOf, int startIndex);
....
[解决办法]
用reflector打开system.dll
[解决办法]
用reflector
同意楼上的同志们详滴

读书人网 >C#

热点推荐