Skip to content
Navigation Menu
{{ message }}
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathStringClass.cs
More file actions
908 lines (859 loc) · 30.7 KB
/
Copy pathStringClass.cs
File metadata and controls
908 lines (859 loc) · 30.7 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
using System.Text;
namespace Stringclass
{
internal class StringClass
{
#region Variables
private char[] _String;
public int Length => _String.Length;
#endregion
#region Constructors and Indexers
public StringClass()
{
_String = Array.Empty<char>();
}
//initial string with creation
public StringClass(string value)
{
_String = value?.ToCharArray() ?? Array.Empty<char>();
}
// get char of array and return string
private StringClass(params char[] chars)
{
_String = chars;
}
// get char by index
public char this[int index]
{
get
{
if (index < 0 || index >= Length)
throw new ArgumentOutOfRangeException(nameof(index));
return _String[index];
}
}
//indexer with position of string , i send position of string and return array of these positions
public char[] this[params int[] indexs]
{
get
{
char[] values = new char[indexs.Length];
for (int i = 0; i < indexs.Length; i++)
{
if (indexs[i] < 0 || indexs[i] >= Length)
throw new ArgumentOutOfRangeException(nameof(indexs));
else
values[i] = _String[indexs[i]];
}
return values;
}
}
#endregion
#region DS_Method
//convert character of array to string
public override string ToString()
{
return new string(_String);
}
//enter a character ,return the first index for that character
public int IndexOf(char c)
{
//validatoin
if (IsNullOrEmpty(_String))
throw new ArgumentNullException(nameof(_String));
//loop on character from start
for (int i = 0; i < _String.Length; i++)
{
//chick if c ==char[i]
if (c == _String[i])
return i;
}
//else return -1
return -1;
}
//enter a character ,return the last index for that character
public int LastIndexOf(char c)
{
//validatoin
if (IsNullOrEmpty(_String))
throw new ArgumentNullException(nameof(_String));
// loop on character from End
for (int i = _String.Length - 1; i >= 0; i--)
{
//chick if c ==char[i]
if (c == _String[i])
return i;
}
//else return -1
return -1;
}
//return part of string
public StringClass Substring(int startIndex, int length)
{
//valadition on input
if (startIndex < 0)
throw new ArgumentOutOfRangeException(nameof(startIndex));
if (length < 0)
throw new ArgumentOutOfRangeException(nameof(length));
if (startIndex + length > Length)
throw new ArgumentOutOfRangeException();
if (IsNullOrEmpty(_String))
throw new ArgumentNullException(nameof(_String));
char[] substring = new char[length];
//loop on substring and assign value from string
for (int i = 0; i < length; i++)
{
//each loop copy character to a new array
substring[i] = _String[i + startIndex];
}
//convert array to string
//retun result
return new StringClass(substring);
}
// replace charcter with another
public StringClass Replace(char oldChar, char newChar)
{
//validatoin
if (IsNullOrEmpty(_String))
throw new ArgumentNullException(nameof(_String));
//create new array of char
char[] result = new char[Length];
//copy old array of character into new array of character
for (int i = 0; i < Length; i++)
{
//check if current char== oldChar assign newChar
result[i] = (_String[i] == oldChar) ? newChar : _String[i];
}
//return new string
return new StringClass(result);
}
public StringClass[] Split(char delimiter)
{
//validatoin
if (IsNullOrEmpty(_String))
throw new ArgumentNullException(nameof(_String));
//decleare new array for Spilt string
List<StringClass> result = new List<StringClass>();
//loop on _string from start
int startPosition = 0;
for (int i = 0; i <= _String.Length; i++)
{
//chick if delimitier == char
if (i != _String.Length && delimiter != _String[i])
continue;
char[] newPart = new char[i - startPosition];
// loop on this part and put in index of array
for (int j = 0; j < newPart.Length; j++)
newPart[j] = _String[startPosition + j];
result.Add(new StringClass(newPart));
startPosition = i + 1;
}
//return array
return result.ToArray();
}
// return number of spasefic char
public int NumberOfChar(char c)
{
//validatoin
if (IsNullOrEmpty(_String))
throw new ArgumentNullException(nameof(_String));
if (_String.Length == 0)
return 0;
int count = 0;
for (int i = 0; i < _String.Length; i++)
{
if (_String[i] == c)
count++;
}
return count;
}
// revers string
public StringClass Reverse()
{
//validatoin
if (IsNullOrEmpty(_String))
throw new ArgumentNullException(nameof(_String));
//decleare new array of char for result
char[] Result = new char[_String.Length];
//loop on _string from last
for (int i = _String.Length - 1; i >= 0; i--)
{
//copy values
Result[_String.Length - i - 1] = _String[i];
}
//return array
return new StringClass(Result);
}
public StringClass Trim()
{
//validatoin
if (IsNullOrEmpty(_String))
throw new ArgumentNullException(nameof(_String));
//loop on _string from start & count number of spacing
int nFirstIndex = 0;
foreach (var item in _String)
{
if (item != ' ')
break;
nFirstIndex++;
}
//loop on _string from End & count number of spacing
int nLastIndex = 0;
for (int i = _String.Length - 1; i >= 0; i--)
{
if (_String[i] != ' ')
break;
nLastIndex++;
}
//create new array for resault with size _string len - count of spacing
int length = _String.Length - nFirstIndex - nLastIndex;
char[] Result = new char[length];
//copy _string to result
for (int i = 0; i < length; i++)
Result[i] = _String[i + nFirstIndex];
//return result
return new StringClass(Result);
}
public StringClass TrimStart()
{
//validatoin
if (IsNullOrEmpty(_String))
throw new ArgumentNullException(nameof(_String));
//loop on _string from start & count number of spacing
int nFirstIndex = 0;
foreach (var item in _String)
{
if (item != ' ')
break;
nFirstIndex++;
}
//create new array for resault with size _string len - count of spacing
int length = _String.Length - nFirstIndex;
char[] Result = new char[length];
//copy _string to result
for (int i = 0; i < length; i++)
Result[i] = _String[i + nFirstIndex];
//return result
return new StringClass(Result);
}
public StringClass TrimEnd()
{
//validatoin
if (IsNullOrEmpty(_String))
throw new ArgumentNullException(nameof(_String));
//loop on _string from End & count number of spacing
int nLastIndex = 0;
for (int i = _String.Length - 1; i >= 0; i--)
{
if (_String[i] != ' ')
break;
nLastIndex++;
}
//create new array for resault with size _string len - count of spacing
int length = _String.Length - nLastIndex;
char[] Result = new char[length];
//copy _string to result
for (int i = 0; i < length; i++)
Result[i] = _String[i];
//return result
return new StringClass(Result);
}
public StringClass RemoveSpacing()
{
//validatoin
if (IsNullOrEmpty(_String))
throw new ArgumentNullException(nameof(_String));
//create result array
List<char> Result = new List<char>();
//loop on string from start
for (int i = 0; i < _String.Length; i++)
{
//check if item != space -->xopy item in result
if (_String[i] == ' ')
continue;
Result.Add(_String[i]);
}
//return result
return new StringClass(Result.ToArray());
}
public override bool Equals(object? obj)
{
if (IsNullOrEmpty(_String))
throw new ArgumentNullException(nameof(_String));
//check if object ==null--> return false
if (obj is null)
return false;
//check if obj is string
if (obj is not StringClass othor)
return false;
//check if length not equal the same --> return false
if (othor.Length != _String.Length) return false;
//loop on one object
//and compare each char with another
for (int i = 0; i < _String.Length; i++)
//if not equal return false
if (othor[i] != _String[i]) return false;
// return true if each char equal another
return true;
}
public override int GetHashCode()
{
if (IsNullOrEmpty(_String))
throw new ArgumentNullException(nameof(_String));
int sum = 0;
//loop on char of _string
for (int i = 0; i < _String.Length; i++)
{
//sum characters
sum += _String[i];
}
//return sum % _string .leng
return sum % _String.Length;
}
public int CompareTo(StringClass Compared)
{
//valadition
if (Compared is null || Compared._String is null || Compared.Length == 0)
throw new ArgumentOutOfRangeException(nameof(Compared));
if (IsNullOrEmpty(_String))
throw new ArgumentNullException(nameof(_String));
//get minmum lenth
int minLength = Math.Min(_String.Length, Compared.Length);
//loop on minmum
for (int i = 0; i < minLength; i++)
{
// if char Compared > _string char return -1
if (Compared[i] > _String[i])
return -1;
// else if char Compared < _string char return 1
else if (Compared[i] < _String[i])
return 1;
}
//compare length
if (_String.Length < Compared.Length)
return -1;
else if (_String.Length > Compared.Length)
return 1;
else
return 0;
}
public static StringClass Join(string seperator, StringClass[] items)
{
//valadion on input
if (items is null || items.Length == 0)
return new StringClass("");
//convert string to StringClass
StringClass seperate = seperator;
// loop and combine strings with seperator in detween
StringClass result = string.Empty;
for (int i = 0; i < items.Length - 1; i++)
{
result += items[i] + seperate;
}
result += items[items.Length - 1];
return result;
}
public bool StartsWith(string word)
{
// input valadition
if (word is null || this is null || word == string.Empty || word.Length > this.Length)
return false;
if (IsNullOrEmpty(_String))
throw new ArgumentNullException(nameof(_String));
//loop on word
for (int i = 0; i < word.Length; i++)
{
//check if _string[i] ==word[i]
if (word[i] != this[i])
return false;
}
return true;
}
public bool EndsWith(string word)
{
// input valadition
if (string.IsNullOrEmpty(word) || this is null || word.Length > this.Length)
return false;
if (IsNullOrEmpty(_String))
throw new ArgumentNullException(nameof(_String));
//loop on word
int count = this.Length - word.Length;
for (int i = 0; i < word.Length; i++)
{
//check if _string[i] ==word[i]
if (word[i] != this[count + i])
return false;
}
return true;
}
public bool Contains(string subString)
{
//input valadition
if (string.IsNullOrEmpty(subString) || subString.Length > this.Length)
return false;
if (IsNullOrEmpty(_String))
throw new ArgumentNullException(nameof(_String));
// loop on string
bool isFound = true;
for (int i = 0; i <= Length - subString.Length; i++)
{
//loop on substring
for (int j = 0; j < subString.Length; j++)
{
isFound = true;
if (subString[j] != _String[i + j])
{
isFound = false;
break;
}
}
if (isFound)
return true;
}
return false;
}
public (bool, int) Searching(string oldString)
{
//valadation
if (string.IsNullOrEmpty(oldString) || oldString.Length > this.Length)
return (false, -1);
if (IsNullOrEmpty(_String))
throw new ArgumentNullException(nameof(_String));
//
bool foundWord;
int indexOfOldWord;
for (int i = 0; i <= _String.Length - oldString.Length; i++)
{
foundWord = true;
//loop on substring
for (int j = 0; j < oldString.Length; j++)
{
//ckeck if _string[x]!=substring[x]-->break
if (_String[i + j] != oldString[j])
{
foundWord = false;
break;
}
}
if (foundWord)
{
indexOfOldWord = i;
return (true, indexOfOldWord);
}
}
//else reurn true and index
return (false, -1);
}
public StringClass[] GetWords()
{
if (IsNullOrEmpty(_String))
{
throw new ArgumentNullException(nameof(_String));
}
//create list for result (unKowen number of Words)
List<StringClass> result = new List<StringClass>();
//create list of char for word
StringBuilder word = new();
//loop on string
bool isSpace = true;
for (int i = 0; i < Length; i++)
{
if (_String[i] != ' ')
{
word.Append(_String[i]);
isSpace = false;
}
else if (isSpace)
{
continue;
}
else
{
result.Add(word.ToString());
isSpace = true;
word.Clear();
}
}
if (!isSpace)
result.Add(word.ToString());
return result.ToArray();
}
public StringClass Insert(int index, string word)
{
// valid input
if (string.IsNullOrEmpty(word) || !(index >= 0 && index <= this.Length))
return _String;
if (IsNullOrEmpty(_String))
throw new ArgumentNullException(nameof(_String));
// create array of char with size =oreginal+word.leng
char[] newString = new char[word.Length + this.Length];
//copy string before index
for (int i = 0; i < index; i++)
newString[i] = _String[i];
// insert word
for (int i = 0; i < word.Length; i++)
newString[i + index] = word[i];
//copy remaining char
for (int j = index; j < _String.Length; j++)
newString[j + word.Length] = _String[j];
return new StringClass(newString);
}
public StringClass Remove(int index, int length)
{
//valadition
if (IsNullOrEmpty(_String))
{
throw new ArgumentNullException(nameof(_String));
}
if ((index + length) > _String.Length || index < 0 || index >= _String.Length || length < 0)
throw new ArgumentOutOfRangeException(nameof(length), nameof(index));
//create array of character with size-length
char[] newString = new char[this.Length - length];
//copy character before index
for (int i = 0; i < index; i++)
{
newString[i] = _String[i];
}
//copy character atrer index to the last index
for (int i = index + length; i < _String.Length; i++)
{
newString[i - length] = _String[i];
}
//return enw string
return new StringClass(newString);
}
public StringClass PadLeft(int totalWidth, char PaddingChar)
{
// valaditon on input
if (totalWidth <= 0 || totalWidth <= this.Length)
return this;
if (IsNullOrEmpty(_String))
{
throw new ArgumentNullException(nameof(_String));
}
//create array of char to represent newString with Total length size
char[] newString = new char[totalWidth];
//copy char to new string from 0 upto totalwidth-_string.length
for (int i = 0; i < totalWidth - _String.Length; i++)
newString[i] = PaddingChar;
// intialize counter
int nCount = 0;
//copy real char
for (int i = totalWidth - _String.Length; i < totalWidth; i++)
newString[i] = _String[nCount++];
//return result
return new StringClass(newString);
}
public StringClass PadRight(int totalWidth, char PaddingChar)
{
// valaditon on input
if (totalWidth <= 0 || totalWidth <= this.Length)
return this;
if (IsNullOrEmpty(_String))
{
throw new ArgumentNullException(nameof(_String));
}
//create array of char to represent newString with Total length size
char[] newString = new char[totalWidth];
//copy char from _string to new String from 0 upto totalwidth-_string.length
for (int i = 0; i < _String.Length; i++)
{
newString[i] = _String[i];
}
//copy real char
for (int i = _String.Length; i < totalWidth; i++)
{
newString[i] = PaddingChar;
}
//return result
return new StringClass(newString);
}
public StringClass ReplaceSubstring(string oldString, string newString)
{
//valadtion on input
if (string.IsNullOrEmpty(oldString) || string.IsNullOrEmpty(newString))
return this;
if (IsNullOrEmpty(_String))
{
throw new ArgumentNullException(nameof(_String));
}
//create new Array of character with (length-oldstring+newstring)
int length = _String.Length - oldString.Length + newString.Length;
char[] result = new char[length];
// ckeck if old string is not contain return _string
var indexOfOldstring = Searching(oldString);
if (!indexOfOldstring.Item1)
return this;
//copy before index
for (int i = 0; i < indexOfOldstring.Item2; i++)
{
result[i] = _String[i];
}
//copy new string
for (int i = 0; i < newString.Length; i++)
{
result[i + indexOfOldstring.Item2] = newString[i];
}
//copy after string
int nCount = indexOfOldstring.Item2 + oldString.Length;
for (int i = indexOfOldstring.Item2 + newString.Length; i < result.Length; i++)
{
result[i] = _String[nCount++];
}
//return new array of string
return new StringClass(result);
}
public StringClass[] SplitByLength(int length)
{
//valadation
if (length <= 0 || length >= _String.Length)
throw new ArgumentOutOfRangeException();
//create size of array = _String.Length / length + _String.Length % length
List<StringClass> SplitedString = new List<StringClass>();
//loop on _string +length
for (int i = 0; i < _String.Length; i += length)
{
int newLength = Math.Min(length, _String.Length - i);
//loop on length
SplitedString.Add(this.Substring(i, newLength));
}
return SplitedString.ToArray();
}
public StringClass Truncate(int length, string str)
{
//validation
if (IsNullOrEmpty(_String))
{
throw new ArgumentOutOfRangeException(nameof(_String));
}
if (length < 0)
{
throw new ArgumentOutOfRangeException(nameof(length));
}
if (str is null)
{
throw new ArgumentNullException(nameof(length));
}
//code
StringClass removedSring = Remove(length, _String.Length - length);
StringClass newString = removedSring.Insert(length, str);
return (newString);
}
public StringClass Normalize()
{
//validation
if (IsNullOrEmpty(_String))
{
throw new ArgumentNullException(nameof(_String));
}
//create result
List<char> result = new List<char>();
bool isSpace = false;
for (int i = 0; i < Length; i++)
{
// if char != space store and false
if (_String[i] != ' ')
{
result.Add(_String[i]);
isSpace = false;
}
//if char == space store--> is space
else if (isSpace)
{
continue;
}
//if char is space -->skip
else if (_String[i] == ' ')
{
result.Add(_String[i]);
isSpace = true;
}
}
return new StringClass(result.ToArray());
}
public StringClass ToTitleCase()
{
//validation
if (IsNullOrEmpty(_String))
{
throw new ArgumentNullException(nameof(_String));
}
//creat new string is array of charcter
char[] newString = new char[this.Length];
//loop on string
bool isFound = true;
for (int i = 0; i < this.Length; i++)
{
//if char after space is char --> is found
if (_String[i] == ' ' && i + 1 < Length && _String[i + 1] != ' ')
{
isFound = true;
}
//and copy items
else if (isFound)
{
newString[i] = char.ToUpper(_String[i]);
isFound = false;
continue;
}
newString[i] = _String[i];
}
//return string
return new StringClass(newString);
}
public StringClass SubstringBefore(string delimiter)
{
//validation
if (IsNullOrEmpty(_String) || IsNullOrEmpty(delimiter))
{
throw new ArgumentNullException(nameof(_String));
}
// indexof word
var index = Searching(delimiter);
//substring of before word
return (index.Item2 < 0) ? new StringClass() : Substring(0, index.Item2);
}
public StringClass SubstringAfter(string delimiter)
{
//validation
if (IsNullOrEmpty(_String) || IsNullOrEmpty(delimiter))
{
throw new ArgumentNullException(nameof(_String));
}
// indexof word
var index = Searching(delimiter);
//substring of before word
int startPoint = index.Item2 + delimiter.Length;
return (index.Item2 < 0) ? new StringClass() : Substring(startPoint, this.Length - startPoint);
}
public StringClass[] SplitLine()
{
//validation
if (IsNullOrEmpty(_String))
{
throw new ArgumentNullException(nameof(_String));
}
//create list of string
List<StringClass> lines = new List<StringClass>();
// loop on string
int startPosition = 0;
for (int i = 0; i < this.Length; i++)
{
//ckeck if char =='\n'
if (this[i] == '\n')
{
//subString for string
StringClass substring = Substring(startPosition, i - startPosition);
startPosition = i + 1;
//add string in list
lines.Add(substring);
}
else if (i == this.Length - 1)
{
//subString for string
StringClass substring = Substring(startPosition, i + 1 - startPosition);
//add string in list
lines.Add(substring);
}
}
return lines.ToArray();
}
// count number of specific character inside stringClass
public int CountOccurrences(char c)
{
//validation
if (IsNullOrEmpty(_String))
{
return 0;
}
int count = 0;
for (int i = 0; i < this.Length; i++)
{
if (this[i] == c)
count++;
}
return count;
}
// return copy from string
public StringClass Clone()
{
if (IsNullOrEmpty(_String))
{
return new StringClass();
}
char[] result = new char[Length];
for (int i = 0; i < Length; i++)
{
result[i] = this[i];
}
return new StringClass(result);
}
public static bool IsNullOrEmpty(StringClass str)
{
if (str is null || str._String == null || str.Length == 0)
return true;
return false;
}
public static bool IsNullOrWhiteSpace(StringClass str)
{
if (str is null || str._String == null || str.Length == 0)
return true;
//
for (int i = 0; i < str.Length; i++)
{
if (str[i] != ' ')
return false;
}
return true;
}
public bool EqualsIgnoreCase(StringClass other)
{
//valadition
if (other is null || other.Length != this.Length)
return false;
if (IsNullOrEmpty(_String))
{
return false;
}
//loop on Length
for (int i = 0; i < this.Length; i++)
{
if (char.ToLower(this[i]) != char.ToLower(other[i]))
return false;
}
return true;
}
#endregion
#region operators
public static implicit operator StringClass(string s)
{
return new StringClass(s);
}
public static implicit operator StringClass(char[] e)
{
return new StringClass(e);
}
public static StringClass operator +(StringClass a, StringClass b)
{
string combined = a.ToString() + b.ToString();
return new StringClass(combined);
}
public static StringClass operator +(StringClass a, string b)
{
string combined = a.ToString() + b;
return new StringClass(combined);
}
public static bool operator ==(StringClass a, StringClass b)
{
if (a is null || b is null)
return false;
return a.Equals(b);
}
public static bool operator !=(StringClass a, StringClass b)
{
return !a.Equals(b);
}
#endregion
}
}
You can’t perform that action at this time.
