5 public static class Extensions
8 /// Get the array slice between the index (inclusive and end of array).
10 public static T
[] Slice
< T
>( this T
[] source
, int start
)
13 T
[] res
= new T
[source
.Length
- start
];
14 for ( int i
= 0; i
< source
.Length
- start
; ++i
)
16 res
[ i
] = source
[ i
+ start
];
22 /// Get the array slice between the two indexes.
23 /// Inclusive for start index, exclusive for end index.
25 public static T
[] Slice
< T
>( this T
[] source
, int start
, int end
)
27 // Handles negative ends
30 end
= source
.Length
- start
- end
- 1;
32 int len
= end
- start
;
36 for ( int i
= 0; i
< len
; ++i
)
38 res
[ i
] = source
[ i
+ start
];
44 /// Get count of arguments ocurances in this string.
46 /// <param name="string"></param>
47 /// <param name="char"></param>
48 /// <returns></returns>
49 public static int Count( this string @string, char @char )
55 index
= @string.IndexOf( @char, index
);
67 /// Replaces this string with the text equivalent of the value of
68 /// specified System.Object instance.
70 /// <param name="string"></param>
71 /// <param name="arg"></param>
72 /// <returns></returns>
73 public static string Fmt( this string @string, object arg
)
75 return String
.Format( @string, arg
);
79 /// Replaces this string with the text equivalent of the value of
80 /// two specified System.Object instances.
82 /// <param name="string"></param>
83 /// <param name="arg0"></param>
84 /// <param name="arg1"></param>
85 /// <returns></returns>
86 public static string Fmt( this string @string, object arg0
, object arg1
)
88 return String
.Format( @string, arg0
, arg1
);
92 /// Replaces this string with the text equivalent of the value of
93 /// three specified System.Object instances.
95 /// <param name="string"></param>
96 /// <param name="arg0"></param>
97 /// <param name="arg1"></param>
98 /// <param name="arg2"></param>
99 /// <returns></returns>
100 public static string Fmt( this string @string, object arg0
, object arg1
, object arg2
)
102 return String
.Format( @string, arg0
, arg1
, arg2
);
107 /// eplaces this string with the text equivalent of the value of
108 /// a corresponding System.Object instance in a specified array.
110 /// <param name="string"></param>
111 /// <param name="args"></param>
112 /// <returns></returns>
113 public static string Fmt( this string @string, params object[] args
)
115 return String
.Format( @string, args
);