-
Notifications
You must be signed in to change notification settings - Fork 1.7k
Expand file tree
/
Copy pathASCIIEncoding.xml
More file actions
1895 lines (1711 loc) · 135 KB
/
ASCIIEncoding.xml
File metadata and controls
1895 lines (1711 loc) · 135 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
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
<Type Name="ASCIIEncoding" FullName="System.Text.ASCIIEncoding">
<TypeSignature Language="C#" Value="public class ASCIIEncoding : System.Text.Encoding" />
<TypeSignature Language="ILAsm" Value=".class public auto ansi beforefieldinit ASCIIEncoding extends System.Text.Encoding" FrameworkAlternate="dotnet-uwp-10.0;net-10.0;net-11.0;net-5.0;net-6.0;net-7.0;net-8.0;net-9.0;netcore-1.0;netcore-1.1;netcore-2.0;netcore-2.1;netcore-2.2;netcore-3.0;netcore-3.1;netstandard-1.3;netstandard-1.4;netstandard-1.6;netstandard-2.0;netstandard-2.1" />
<TypeSignature Language="DocId" Value="T:System.Text.ASCIIEncoding" />
<TypeSignature Language="VB.NET" Value="Public Class ASCIIEncoding
Inherits Encoding" />
<TypeSignature Language="F#" Value="type ASCIIEncoding = class
 inherit Encoding" />
<TypeSignature Language="C++ CLI" Value="public ref class ASCIIEncoding : System::Text::Encoding" />
<TypeSignature Language="ILAsm" Value=".class public auto ansi serializable beforefieldinit ASCIIEncoding extends System.Text.Encoding" FrameworkAlternate="netframework-1.1;netframework-2.0;netframework-3.0;netframework-3.5;netframework-4.0;netframework-4.5;netframework-4.5.1;netframework-4.5.2;netframework-4.6;netframework-4.6.1;netframework-4.6.2;netframework-4.7;netframework-4.7.1;netframework-4.7.2;netframework-4.8;netframework-4.8.1" />
<AssemblyInfo>
<AssemblyName>System.Text.Encoding.Extensions</AssemblyName>
<AssemblyVersion>4.0.10.0</AssemblyVersion>
<AssemblyVersion>4.1.0.0</AssemblyVersion>
<AssemblyVersion>4.1.1.0</AssemblyVersion>
<AssemblyVersion>4.1.2.0</AssemblyVersion>
<AssemblyVersion>5.0.0.0</AssemblyVersion>
<AssemblyVersion>6.0.0.0</AssemblyVersion>
<AssemblyVersion>7.0.0.0</AssemblyVersion>
<AssemblyVersion>8.0.0.0</AssemblyVersion>
<AssemblyVersion>9.0.0.0</AssemblyVersion>
<AssemblyVersion>10.0.0.0</AssemblyVersion>
<AssemblyVersion>11.0.0.0</AssemblyVersion>
</AssemblyInfo>
<AssemblyInfo>
<AssemblyName>mscorlib</AssemblyName>
<AssemblyVersion>1.0.5000.0</AssemblyVersion>
<AssemblyVersion>2.0.0.0</AssemblyVersion>
<AssemblyVersion>2.0.5.0</AssemblyVersion>
<AssemblyVersion>4.0.0.0</AssemblyVersion>
</AssemblyInfo>
<AssemblyInfo>
<AssemblyName>netstandard</AssemblyName>
<AssemblyVersion>2.0.0.0</AssemblyVersion>
<AssemblyVersion>2.1.0.0</AssemblyVersion>
</AssemblyInfo>
<TypeForwardingChain>
<TypeForwarding From="netstandard" FromVersion="2.1.0.0" To="System.Text.Encoding.Extensions" ToVersion="10.0.0.0" FrameworkAlternate="net-10.0" />
<TypeForwarding From="netstandard" FromVersion="2.1.0.0" To="System.Text.Encoding.Extensions" ToVersion="11.0.0.0" FrameworkAlternate="net-11.0" />
<TypeForwarding From="netstandard" FromVersion="2.1.0.0" To="System.Text.Encoding.Extensions" ToVersion="5.0.0.0" FrameworkAlternate="net-5.0" />
<TypeForwarding From="netstandard" FromVersion="2.1.0.0" To="System.Text.Encoding.Extensions" ToVersion="6.0.0.0" FrameworkAlternate="net-6.0" />
<TypeForwarding From="netstandard" FromVersion="2.1.0.0" To="System.Text.Encoding.Extensions" ToVersion="7.0.0.0" FrameworkAlternate="net-7.0" />
<TypeForwarding From="netstandard" FromVersion="2.1.0.0" To="System.Text.Encoding.Extensions" ToVersion="8.0.0.0" FrameworkAlternate="net-8.0" />
<TypeForwarding From="netstandard" FromVersion="2.1.0.0" To="System.Text.Encoding.Extensions" ToVersion="9.0.0.0" FrameworkAlternate="net-9.0" />
</TypeForwardingChain>
<Base>
<BaseTypeName>System.Text.Encoding</BaseTypeName>
</Base>
<Interfaces />
<Attributes>
<Attribute FrameworkAlternate="netframework-1.1;netframework-2.0;netframework-3.0;netframework-3.5;netframework-4.0;netframework-4.5;netframework-4.5.1;netframework-4.5.2;netframework-4.6;netframework-4.6.1;netframework-4.6.2;netframework-4.7;netframework-4.7.1;netframework-4.7.2;netframework-4.8;netframework-4.8.1">
<AttributeName Language="C#">[System.Serializable]</AttributeName>
<AttributeName Language="F#">[<System.Serializable>]</AttributeName>
</Attribute>
<Attribute FrameworkAlternate="netframework-2.0;netframework-3.0;netframework-3.5;netframework-4.0;netframework-4.5;netframework-4.5.1;netframework-4.5.2;netframework-4.6;netframework-4.6.1;netframework-4.6.2;netframework-4.7;netframework-4.7.1;netframework-4.7.2;netframework-4.8;netframework-4.8.1">
<AttributeName Language="C#">[System.Runtime.InteropServices.ComVisible(true)]</AttributeName>
<AttributeName Language="F#">[<System.Runtime.InteropServices.ComVisible(true)>]</AttributeName>
</Attribute>
</Attributes>
<Docs>
<summary>Represents an ASCII character encoding of Unicode characters.</summary>
<remarks>
<format type="text/markdown"><![CDATA[
## Remarks
Encoding is the process of transforming a set of Unicode characters into a sequence of bytes. Decoding is the process of transforming a sequence of encoded bytes into a set of Unicode characters.
<xref:System.Text.ASCIIEncoding> corresponds to the Windows code page 20127. Because ASCII is a 7-bit encoding, ASCII characters are limited to the lowest 128 Unicode characters, from U+0000 to U+007F. If you use the default encoder returned by the <xref:System.Text.Encoding.ASCII%2A?displayProperty=nameWithType> property or the <xref:System.Text.ASCIIEncoding.%23ctor%2A> constructor, characters outside that range are replaced with a question mark (?) before the encoding operation is performed. Because the <xref:System.Text.ASCIIEncoding> class supports only a limited character set, the <xref:System.Text.UTF8Encoding>, <xref:System.Text.UnicodeEncoding>, and <xref:System.Text.UTF32Encoding> classes are better suited for globalized applications. The following considerations can help you to decide whether to use <xref:System.Text.ASCIIEncoding>:
- Some protocols require ASCII or a subset of ASCII. In these cases ASCII encoding is appropriate.
- If an 8-bit encoding is expected, then ASCII probably isn't the correct choice. Instead, consider using UTF8 instead of ASCII. For the characters U+0000 through U+007F, the results are identical, but all Unicode characters are representable in UTF-8, which avoids data loss.
> [!CAUTION]
> <xref:System.Text.ASCIIEncoding> does not provide error detection. For security reasons, you should use <xref:System.Text.UTF8Encoding>, <xref:System.Text.UnicodeEncoding>, or <xref:System.Text.UTF32Encoding> and enable error detection.
The <xref:System.Text.ASCIIEncoding.GetByteCount%2A> method determines how many bytes result in encoding a set of Unicode characters, and the <xref:System.Text.ASCIIEncoding.GetBytes%2A> method performs the actual encoding.
Likewise, the <xref:System.Text.ASCIIEncoding.GetCharCount%2A> method determines how many characters result in decoding a sequence of bytes, and the <xref:System.Text.ASCIIEncoding.GetChars%2A> and <xref:System.Text.ASCIIEncoding.GetString%2A> methods perform the actual decoding.
Note that the default <xref:System.Text.ASCIIEncoding> constructor by itself might not have the appropriate behavior for your application. You might want to consider setting the <xref:System.Text.Encoding.EncoderFallback%2A> or <xref:System.Text.Encoding.DecoderFallback%2A> property to <xref:System.Text.EncoderExceptionFallback> or <xref:System.Text.DecoderExceptionFallback> to prevent sequences with the 8th bit set. Custom behavior might also be appropriate for these cases.
## Examples
The following example demonstrates how to encode Unicode characters into ASCII. Notice the loss of data that occurs when your application uses <xref:System.Text.ASCIIEncoding> to encode Unicode characters outside of the ASCII range.
:::code language="csharp" source="~/snippets/csharp/System.Text/ASCIIEncoding/Overview/snippet.cs" id="Snippet1":::
:::code language="vb" source="~/snippets/visualbasic/System.Text/ASCIIEncoding/Overview/snippet.vb" id="Snippet1":::
]]></format>
</remarks>
<altmember cref="T:System.Text.Decoder" />
<altmember cref="T:System.Text.Encoder" />
<related type="Article" href="/dotnet/standard/base-types/character-encoding">Understanding Encodings</related>
</Docs>
<Members>
<Member MemberName=".ctor">
<MemberSignature Language="C#" Value="public ASCIIEncoding ();" />
<MemberSignature Language="ILAsm" Value=".method public hidebysig specialname rtspecialname instance void .ctor() cil managed" />
<MemberSignature Language="DocId" Value="M:System.Text.ASCIIEncoding.#ctor" />
<MemberSignature Language="VB.NET" Value="Public Sub New ()" />
<MemberSignature Language="C++ CLI" Value="public:
 ASCIIEncoding();" />
<MemberType>Constructor</MemberType>
<AssemblyInfo>
<AssemblyName>System.Text.Encoding.Extensions</AssemblyName>
<AssemblyVersion>4.0.10.0</AssemblyVersion>
<AssemblyVersion>4.1.0.0</AssemblyVersion>
<AssemblyVersion>4.1.1.0</AssemblyVersion>
<AssemblyVersion>4.1.2.0</AssemblyVersion>
<AssemblyVersion>5.0.0.0</AssemblyVersion>
<AssemblyVersion>6.0.0.0</AssemblyVersion>
<AssemblyVersion>7.0.0.0</AssemblyVersion>
<AssemblyVersion>8.0.0.0</AssemblyVersion>
<AssemblyVersion>9.0.0.0</AssemblyVersion>
<AssemblyVersion>10.0.0.0</AssemblyVersion>
<AssemblyVersion>11.0.0.0</AssemblyVersion>
</AssemblyInfo>
<AssemblyInfo>
<AssemblyName>mscorlib</AssemblyName>
<AssemblyVersion>1.0.5000.0</AssemblyVersion>
<AssemblyVersion>2.0.0.0</AssemblyVersion>
<AssemblyVersion>2.0.5.0</AssemblyVersion>
<AssemblyVersion>4.0.0.0</AssemblyVersion>
</AssemblyInfo>
<AssemblyInfo>
<AssemblyName>netstandard</AssemblyName>
<AssemblyVersion>2.0.0.0</AssemblyVersion>
<AssemblyVersion>2.1.0.0</AssemblyVersion>
</AssemblyInfo>
<Parameters />
<Docs>
<summary>Initializes a new instance of the <see cref="T:System.Text.ASCIIEncoding" /> class.</summary>
<remarks>
<format type="text/markdown"><![CDATA[
## Remarks
> [!CAUTION]
> The <xref:System.Text.ASCIIEncoding> class does not provide error detection. For security reasons, you should use the <xref:System.Text.UTF8Encoding>, <xref:System.Text.UnicodeEncoding>, or <xref:System.Text.UTF32Encoding> class and enable error detection.
If you choose to use ASCII encoding, this constructor may not provide the appropriate fallback behavior for your application. It uses the <xref:System.Text.EncoderReplacementFallback> and <xref:System.Text.DecoderReplacementFallback> classes to replace every character outside the range of U+0000 through U+007F with a question mark (?). Instead, you can call the <xref:System.Text.Encoding.GetEncoding%28System.Int32%2CSystem.Text.EncoderFallback%2CSystem.Text.DecoderFallback%29?displayProperty=nameWithType> or <xref:System.Text.Encoding.GetEncoding%28System.String%2CSystem.Text.EncoderFallback%2CSystem.Text.DecoderFallback%29?displayProperty=nameWithType> method and pass it <xref:System.Text.EncoderExceptionFallback> and <xref:System.Text.DecoderExceptionFallback> objects to use exception fallback.
> [!NOTE]
> <xref:System.Text.ASCIIEncoding> supports only the Unicode character values between U+0000 and U+007F. Therefore, <xref:System.Text.UTF8Encoding>, <xref:System.Text.UnicodeEncoding>, and <xref:System.Text.UTF32Encoding> are better suited for globalized applications.
## Examples
The following example demonstrates how to create a new <xref:System.Text.ASCIIEncoding> instance and display the name of the encoding.
:::code language="csharp" source="~/snippets/csharp/System.Text/ASCIIEncoding/.ctor/ctor.cs" id="Snippet1":::
:::code language="vb" source="~/snippets/visualbasic/System.Text/ASCIIEncoding/.ctor/ctor.vb" id="Snippet1":::
]]></format>
</remarks>
</Docs>
</Member>
<MemberGroup MemberName="GetByteCount">
<AssemblyInfo>
<AssemblyName>System.Text.Encoding.Extensions</AssemblyName>
<AssemblyVersion>4.0.10.0</AssemblyVersion>
<AssemblyVersion>4.1.0.0</AssemblyVersion>
</AssemblyInfo>
<Docs>
<summary>Calculates the number of bytes produced by encoding a set of characters.</summary>
</Docs>
</MemberGroup>
<Member MemberName="GetByteCount">
<MemberSignature Language="C#" Value="public override int GetByteCount (ReadOnlySpan<char> chars);" />
<MemberSignature Language="ILAsm" Value=".method public hidebysig virtual instance int32 GetByteCount(valuetype System.ReadOnlySpan`1<char> chars) cil managed" />
<MemberSignature Language="DocId" Value="M:System.Text.ASCIIEncoding.GetByteCount(System.ReadOnlySpan{System.Char})" />
<MemberSignature Language="VB.NET" Value="Public Overrides Function GetByteCount (chars As ReadOnlySpan(Of Char)) As Integer" />
<MemberSignature Language="F#" Value="override this.GetByteCount : ReadOnlySpan<char> -> int" Usage="aSCIIEncoding.GetByteCount chars" />
<MemberSignature Language="C++ CLI" Value="public:
 override int GetByteCount(ReadOnlySpan<char> chars);" />
<MemberType>Method</MemberType>
<AssemblyInfo>
<AssemblyName>System.Text.Encoding.Extensions</AssemblyName>
<AssemblyVersion>4.1.1.0</AssemblyVersion>
<AssemblyVersion>4.1.2.0</AssemblyVersion>
<AssemblyVersion>5.0.0.0</AssemblyVersion>
<AssemblyVersion>6.0.0.0</AssemblyVersion>
<AssemblyVersion>7.0.0.0</AssemblyVersion>
<AssemblyVersion>8.0.0.0</AssemblyVersion>
<AssemblyVersion>9.0.0.0</AssemblyVersion>
<AssemblyVersion>10.0.0.0</AssemblyVersion>
<AssemblyVersion>11.0.0.0</AssemblyVersion>
</AssemblyInfo>
<AssemblyInfo>
<AssemblyName>mscorlib</AssemblyName>
</AssemblyInfo>
<AssemblyInfo>
<AssemblyName>netstandard</AssemblyName>
</AssemblyInfo>
<ReturnValue>
<ReturnType>System.Int32</ReturnType>
</ReturnValue>
<Parameters>
<Parameter Name="chars" Type="System.ReadOnlySpan<System.Char>" Index="0" FrameworkAlternate="netcore-3.0;netcore-3.1;net-5.0;net-6.0;net-7.0;net-8.0;net-9.0;net-10.0;net-11.0" />
</Parameters>
<Docs>
<param name="chars">The span that contains the set of characters to encode.</param>
<summary>Calculates the number of bytes produced by encoding the specified character span.</summary>
<returns>The number of bytes produced by encoding the specified character span.</returns>
<remarks>
<format type="text/markdown"><![CDATA[
## Remarks
To calculate the exact size required by <xref:System.Text.ASCIIEncoding.GetBytes%2A> to store the resulting bytes, use <xref:System.Text.ASCIIEncoding.GetByteCount%2A>. To calculate the maximum size, use <xref:System.Text.ASCIIEncoding.GetMaxByteCount%2A>. The <xref:System.Text.ASCIIEncoding.GetByteCount%2A> method generally allows allocation of less memory, while the <xref:System.Text.ASCIIEncoding.GetMaxByteCount%2A> method generally executes faster.
]]></format>
</remarks>
</Docs>
</Member>
<Member MemberName="GetByteCount">
<MemberSignature Language="C#" Value="public override int GetByteCount (string chars);" />
<MemberSignature Language="ILAsm" Value=".method public hidebysig virtual instance int32 GetByteCount(string chars) cil managed" />
<MemberSignature Language="DocId" Value="M:System.Text.ASCIIEncoding.GetByteCount(System.String)" />
<MemberSignature Language="VB.NET" Value="Public Overrides Function GetByteCount (chars As String) As Integer" />
<MemberSignature Language="F#" Value="override this.GetByteCount : string -> int" Usage="aSCIIEncoding.GetByteCount chars" />
<MemberSignature Language="C++ CLI" Value="public:
 override int GetByteCount(System::String ^ chars);" />
<MemberType>Method</MemberType>
<AssemblyInfo>
<AssemblyName>System.Text.Encoding.Extensions</AssemblyName>
<AssemblyVersion>4.0.10.0</AssemblyVersion>
<AssemblyVersion>4.1.0.0</AssemblyVersion>
<AssemblyVersion>4.1.1.0</AssemblyVersion>
<AssemblyVersion>4.1.2.0</AssemblyVersion>
<AssemblyVersion>5.0.0.0</AssemblyVersion>
<AssemblyVersion>6.0.0.0</AssemblyVersion>
<AssemblyVersion>7.0.0.0</AssemblyVersion>
<AssemblyVersion>8.0.0.0</AssemblyVersion>
<AssemblyVersion>9.0.0.0</AssemblyVersion>
<AssemblyVersion>10.0.0.0</AssemblyVersion>
<AssemblyVersion>11.0.0.0</AssemblyVersion>
</AssemblyInfo>
<AssemblyInfo>
<AssemblyName>mscorlib</AssemblyName>
<AssemblyVersion>1.0.5000.0</AssemblyVersion>
<AssemblyVersion>2.0.0.0</AssemblyVersion>
<AssemblyVersion>2.0.5.0</AssemblyVersion>
<AssemblyVersion>4.0.0.0</AssemblyVersion>
</AssemblyInfo>
<AssemblyInfo>
<AssemblyName>netstandard</AssemblyName>
<AssemblyVersion>2.0.0.0</AssemblyVersion>
<AssemblyVersion>2.1.0.0</AssemblyVersion>
</AssemblyInfo>
<Attributes>
<Attribute FrameworkAlternate="netframework-4.0;netframework-4.5;netframework-4.5.1;netframework-4.5.2;netframework-4.6;netframework-4.6.1;netframework-4.6.2;netframework-4.7;netframework-4.7.1;netframework-4.7.2;netframework-4.8;netframework-4.8.1">
<AttributeName Language="C#">[System.Security.SecuritySafeCritical]</AttributeName>
<AttributeName Language="F#">[<System.Security.SecuritySafeCritical>]</AttributeName>
</Attribute>
</Attributes>
<ReturnValue>
<ReturnType>System.Int32</ReturnType>
</ReturnValue>
<Parameters>
<Parameter Name="chars" Type="System.String" />
</Parameters>
<Docs>
<param name="chars">The <see cref="T:System.String" /> containing the set of characters to encode.</param>
<summary>Calculates the number of bytes produced by encoding the characters in the specified <see cref="T:System.String" />.</summary>
<returns>The number of bytes produced by encoding the specified characters.</returns>
<remarks>
<format type="text/markdown"><![CDATA[
## Remarks
To calculate the exact array size required by <xref:System.Text.ASCIIEncoding.GetBytes%2A> to store the resulting bytes, the application uses <xref:System.Text.ASCIIEncoding.GetByteCount%2A>. To calculate the maximum array size, the application should use <xref:System.Text.ASCIIEncoding.GetMaxByteCount%2A>. The <xref:System.Text.ASCIIEncoding.GetByteCount%2A> method generally allows allocation of less memory, while the <xref:System.Text.ASCIIEncoding.GetMaxByteCount%2A> method generally executes faster.
## Examples
The following example demonstrates how to use the <xref:System.Text.ASCIIEncoding.GetByteCount%2A> method to return the number of bytes required to encode a string using <xref:System.Text.ASCIIEncoding>.
:::code language="csharp" source="~/snippets/csharp/System.Text/ASCIIEncoding/GetByteCount/getbytecount-string.cs" id="Snippet1":::
:::code language="vb" source="~/snippets/visualbasic/System.Text/ASCIIEncoding/GetByteCount/getbytecount-string.vb" id="Snippet1":::
]]></format>
</remarks>
<exception cref="T:System.ArgumentNullException">
<paramref name="chars" /> is <see langword="null" />.</exception>
<exception cref="T:System.ArgumentOutOfRangeException">The resulting number of bytes is greater than the maximum number that can be returned as an integer.</exception>
<exception cref="T:System.Text.EncoderFallbackException">A fallback occurred (for more information, see <see href="https://learn.microsoft.com/dotnet/standard/base-types/character-encoding">Character Encoding in .NET</see>)
-and-
<see cref="P:System.Text.Encoding.EncoderFallback" /> is set to <see cref="T:System.Text.EncoderExceptionFallback" />.</exception>
<altmember cref="M:System.Text.ASCIIEncoding.GetBytes(System.String,System.Int32,System.Int32,System.Byte[],System.Int32)" />
<altmember cref="M:System.Text.ASCIIEncoding.GetMaxByteCount(System.Int32)" />
<altmember cref="M:System.Text.ASCIIEncoding.GetEncoder" />
<related type="Article" href="/dotnet/standard/base-types/character-encoding">Understanding Encodings</related>
</Docs>
</Member>
<Member MemberName="GetByteCount">
<MemberSignature Language="C#" Value="public override int GetByteCount (char* chars, int count);" />
<MemberSignature Language="ILAsm" Value=".method public hidebysig virtual instance int32 GetByteCount(char* chars, int32 count) cil managed" />
<MemberSignature Language="DocId" Value="M:System.Text.ASCIIEncoding.GetByteCount(System.Char*,System.Int32)" />
<MemberSignature Language="F#" Value="override this.GetByteCount : nativeptr<char> * int -> int" Usage="aSCIIEncoding.GetByteCount (chars, count)" />
<MemberSignature Language="C++ CLI" Value="public:
 override int GetByteCount(char* chars, int count);" />
<MemberType>Method</MemberType>
<AssemblyInfo>
<AssemblyName>System.Text.Encoding.Extensions</AssemblyName>
<AssemblyVersion>4.0.10.0</AssemblyVersion>
<AssemblyVersion>4.1.0.0</AssemblyVersion>
<AssemblyVersion>4.1.1.0</AssemblyVersion>
<AssemblyVersion>4.1.2.0</AssemblyVersion>
<AssemblyVersion>5.0.0.0</AssemblyVersion>
<AssemblyVersion>6.0.0.0</AssemblyVersion>
<AssemblyVersion>7.0.0.0</AssemblyVersion>
<AssemblyVersion>8.0.0.0</AssemblyVersion>
<AssemblyVersion>9.0.0.0</AssemblyVersion>
<AssemblyVersion>10.0.0.0</AssemblyVersion>
<AssemblyVersion>11.0.0.0</AssemblyVersion>
</AssemblyInfo>
<AssemblyInfo>
<AssemblyName>mscorlib</AssemblyName>
<AssemblyVersion>2.0.0.0</AssemblyVersion>
<AssemblyVersion>2.0.5.0</AssemblyVersion>
<AssemblyVersion>4.0.0.0</AssemblyVersion>
</AssemblyInfo>
<AssemblyInfo>
<AssemblyName>netstandard</AssemblyName>
<AssemblyVersion>2.0.0.0</AssemblyVersion>
<AssemblyVersion>2.1.0.0</AssemblyVersion>
</AssemblyInfo>
<Attributes>
<Attribute FrameworkAlternate="dotnet-uwp-10.0;net-10.0;net-11.0;net-5.0;net-6.0;net-7.0;net-8.0;net-9.0;netcore-1.0;netcore-1.1;netcore-2.0;netcore-2.1;netcore-2.2;netcore-3.0;netcore-3.1;netframework-2.0;netframework-3.0;netframework-3.5;netframework-4.0;netframework-4.5;netframework-4.5.1;netframework-4.5.2;netframework-4.6;netframework-4.6.1;netframework-4.6.2;netframework-4.7;netframework-4.7.1;netframework-4.7.2;netframework-4.8;netframework-4.8.1;netstandard-1.3;netstandard-1.4;netstandard-1.6;netstandard-2.0;netstandard-2.1">
<AttributeName Language="C#">[System.CLSCompliant(false)]</AttributeName>
<AttributeName Language="F#">[<System.CLSCompliant(false)>]</AttributeName>
</Attribute>
<Attribute FrameworkAlternate="dotnet-uwp-10.0;netcore-1.0;netcore-1.1;netcore-2.0;netframework-4.0;netframework-4.5;netframework-4.5.1;netframework-4.5.2;netframework-4.6;netframework-4.6.1;netframework-4.6.2;netframework-4.7;netframework-4.7.1;netframework-4.7.2;netframework-4.8;netframework-4.8.1;netstandard-1.3;netstandard-1.4;netstandard-1.6">
<AttributeName Language="C#">[System.Security.SecurityCritical]</AttributeName>
<AttributeName Language="F#">[<System.Security.SecurityCritical>]</AttributeName>
</Attribute>
<Attribute FrameworkAlternate="netframework-2.0;netframework-3.0;netframework-3.5;netframework-4.0;netframework-4.5;netframework-4.5.1;netframework-4.5.2;netframework-4.6;netframework-4.6.1;netframework-4.6.2;netframework-4.7;netframework-4.7.1;netframework-4.7.2;netframework-4.8;netframework-4.8.1">
<AttributeName Language="C#">[System.Runtime.InteropServices.ComVisible(false)]</AttributeName>
<AttributeName Language="F#">[<System.Runtime.InteropServices.ComVisible(false)>]</AttributeName>
</Attribute>
</Attributes>
<ReturnValue>
<ReturnType>System.Int32</ReturnType>
</ReturnValue>
<Parameters>
<Parameter Name="chars" Type="System.Char*" Index="0" FrameworkAlternate="dotnet-uwp-10.0;net-10.0;net-11.0;net-5.0;net-6.0;net-7.0;net-8.0;net-9.0;netcore-1.0;netcore-1.1;netcore-2.0;netcore-2.1;netcore-2.2;netcore-3.0;netcore-3.1;netframework-2.0;netframework-3.0;netframework-3.5;netframework-4.0;netframework-4.5;netframework-4.5.1;netframework-4.5.2;netframework-4.6;netframework-4.6.1;netframework-4.6.2;netframework-4.7;netframework-4.7.1;netframework-4.7.2;netframework-4.8;netframework-4.8.1;netstandard-1.3;netstandard-1.4;netstandard-1.6;netstandard-2.0;netstandard-2.1" />
<Parameter Name="count" Type="System.Int32" Index="1" FrameworkAlternate="dotnet-uwp-10.0;net-10.0;net-11.0;net-5.0;net-6.0;net-7.0;net-8.0;net-9.0;netcore-1.0;netcore-1.1;netcore-2.0;netcore-2.1;netcore-2.2;netcore-3.0;netcore-3.1;netframework-2.0;netframework-3.0;netframework-3.5;netframework-4.0;netframework-4.5;netframework-4.5.1;netframework-4.5.2;netframework-4.6;netframework-4.6.1;netframework-4.6.2;netframework-4.7;netframework-4.7.1;netframework-4.7.2;netframework-4.8;netframework-4.8.1;netstandard-1.3;netstandard-1.4;netstandard-1.6;netstandard-2.0;netstandard-2.1" />
</Parameters>
<Docs>
<param name="chars">A pointer to the first character to encode.</param>
<param name="count">The number of characters to encode.</param>
<summary>Calculates the number of bytes produced by encoding a set of characters starting at the specified character pointer.</summary>
<returns>The number of bytes produced by encoding the specified characters.</returns>
<remarks>
<format type="text/markdown"><![CDATA[
## Remarks
To calculate the exact array size required by <xref:System.Text.ASCIIEncoding.GetBytes%2A> to store the resulting bytes, the application uses <xref:System.Text.ASCIIEncoding.GetByteCount%2A>. To calculate the maximum array size, the application should use <xref:System.Text.ASCIIEncoding.GetMaxByteCount%2A>. The <xref:System.Text.ASCIIEncoding.GetByteCount%2A> method generally allows allocation of less memory, while the <xref:System.Text.ASCIIEncoding.GetMaxByteCount%2A> method generally executes faster.
]]></format>
</remarks>
<altCompliant cref="M:System.Text.ASCIIEncoding.GetByteCount(System.Char[],System.Int32,System.Int32)" />
<exception cref="T:System.ArgumentNullException">
<paramref name="chars" /> is <see langword="null" />.</exception>
<exception cref="T:System.ArgumentOutOfRangeException">
<paramref name="count" /> is less than zero.
-or-
The resulting number of bytes is greater than the maximum number that can be returned as an integer.</exception>
<exception cref="T:System.Text.EncoderFallbackException">A fallback occurred (for more information, see <see href="https://learn.microsoft.com/dotnet/standard/base-types/character-encoding">Character Encoding in .NET</see>)
-and-
<see cref="P:System.Text.Encoding.EncoderFallback" /> is set to <see cref="T:System.Text.EncoderExceptionFallback" />.</exception>
<altmember cref="M:System.Text.ASCIIEncoding.GetBytes(System.String,System.Int32,System.Int32,System.Byte[],System.Int32)" />
<altmember cref="M:System.Text.ASCIIEncoding.GetMaxByteCount(System.Int32)" />
<altmember cref="M:System.Text.ASCIIEncoding.GetEncoder" />
</Docs>
</Member>
<Member MemberName="GetByteCount">
<MemberSignature Language="C#" Value="public override int GetByteCount (char[] chars, int index, int count);" />
<MemberSignature Language="ILAsm" Value=".method public hidebysig virtual instance int32 GetByteCount(char[] chars, int32 index, int32 count) cil managed" />
<MemberSignature Language="DocId" Value="M:System.Text.ASCIIEncoding.GetByteCount(System.Char[],System.Int32,System.Int32)" />
<MemberSignature Language="VB.NET" Value="Public Overrides Function GetByteCount (chars As Char(), index As Integer, count As Integer) As Integer" />
<MemberSignature Language="F#" Value="override this.GetByteCount : char[] * int * int -> int" Usage="aSCIIEncoding.GetByteCount (chars, index, count)" />
<MemberSignature Language="C++ CLI" Value="public:
 override int GetByteCount(cli::array <char> ^ chars, int index, int count);" />
<MemberType>Method</MemberType>
<AssemblyInfo>
<AssemblyName>System.Text.Encoding.Extensions</AssemblyName>
<AssemblyVersion>4.0.10.0</AssemblyVersion>
<AssemblyVersion>4.1.0.0</AssemblyVersion>
<AssemblyVersion>4.1.1.0</AssemblyVersion>
<AssemblyVersion>4.1.2.0</AssemblyVersion>
<AssemblyVersion>5.0.0.0</AssemblyVersion>
<AssemblyVersion>6.0.0.0</AssemblyVersion>
<AssemblyVersion>7.0.0.0</AssemblyVersion>
<AssemblyVersion>8.0.0.0</AssemblyVersion>
<AssemblyVersion>9.0.0.0</AssemblyVersion>
<AssemblyVersion>10.0.0.0</AssemblyVersion>
<AssemblyVersion>11.0.0.0</AssemblyVersion>
</AssemblyInfo>
<AssemblyInfo>
<AssemblyName>mscorlib</AssemblyName>
<AssemblyVersion>1.0.5000.0</AssemblyVersion>
<AssemblyVersion>2.0.0.0</AssemblyVersion>
<AssemblyVersion>2.0.5.0</AssemblyVersion>
<AssemblyVersion>4.0.0.0</AssemblyVersion>
</AssemblyInfo>
<AssemblyInfo>
<AssemblyName>netstandard</AssemblyName>
<AssemblyVersion>2.0.0.0</AssemblyVersion>
<AssemblyVersion>2.1.0.0</AssemblyVersion>
</AssemblyInfo>
<Attributes>
<Attribute FrameworkAlternate="netframework-4.0;netframework-4.5;netframework-4.5.1;netframework-4.5.2;netframework-4.6;netframework-4.6.1;netframework-4.6.2;netframework-4.7;netframework-4.7.1;netframework-4.7.2;netframework-4.8;netframework-4.8.1">
<AttributeName Language="C#">[System.Security.SecuritySafeCritical]</AttributeName>
<AttributeName Language="F#">[<System.Security.SecuritySafeCritical>]</AttributeName>
</Attribute>
</Attributes>
<ReturnValue>
<ReturnType>System.Int32</ReturnType>
</ReturnValue>
<Parameters>
<Parameter Name="chars" Type="System.Char[]" />
<Parameter Name="index" Type="System.Int32" />
<Parameter Name="count" Type="System.Int32" />
</Parameters>
<Docs>
<param name="chars">The character array containing the set of characters to encode.</param>
<param name="index">The index of the first character to encode.</param>
<param name="count">The number of characters to encode.</param>
<summary>Calculates the number of bytes produced by encoding a set of characters from the specified character array.</summary>
<returns>The number of bytes produced by encoding the specified characters.</returns>
<remarks>
<format type="text/markdown"><![CDATA[
## Remarks
To calculate the exact array size required by <xref:System.Text.ASCIIEncoding.GetBytes%2A> to store the resulting bytes, the application uses <xref:System.Text.ASCIIEncoding.GetByteCount%2A>. To calculate the maximum array size, the application should use <xref:System.Text.ASCIIEncoding.GetMaxByteCount%2A>. The <xref:System.Text.ASCIIEncoding.GetByteCount%2A> method generally allows allocation of less memory, while the <xref:System.Text.ASCIIEncoding.GetMaxByteCount%2A> method generally executes faster.
## Examples
The following example demonstrates how to use the <xref:System.Text.ASCIIEncoding.GetByteCount%2A> method to return the number of bytes required to encode an array of Unicode characters using <xref:System.Text.ASCIIEncoding>.
:::code language="csharp" source="~/snippets/csharp/System.Text/ASCIIEncoding/GetByteCount/getbytecount-char[]-int32-int32.cs" id="Snippet1":::
:::code language="vb" source="~/snippets/visualbasic/System.Text/ASCIIEncoding/GetByteCount/getbytecount-char[]-int32-int32.vb" id="Snippet1":::
]]></format>
</remarks>
<exception cref="T:System.ArgumentNullException">
<paramref name="chars" /> is <see langword="null" />.</exception>
<exception cref="T:System.ArgumentOutOfRangeException">
<paramref name="index" /> or <paramref name="count" /> is less than zero.
-or-
<paramref name="index" /> and <paramref name="count" /> do not denote a valid range in <paramref name="chars" />.
-or-
The resulting number of bytes is greater than the maximum number that can be returned as an integer.</exception>
<exception cref="T:System.Text.EncoderFallbackException">A fallback occurred (for more information, see <see href="https://learn.microsoft.com/dotnet/standard/base-types/character-encoding">Character Encoding in .NET</see>)
-and-
<see cref="P:System.Text.Encoding.EncoderFallback" /> is set to <see cref="T:System.Text.EncoderExceptionFallback" />.</exception>
<altmember cref="M:System.Text.ASCIIEncoding.GetBytes(System.String,System.Int32,System.Int32,System.Byte[],System.Int32)" />
<altmember cref="M:System.Text.ASCIIEncoding.GetMaxByteCount(System.Int32)" />
<altmember cref="M:System.Text.ASCIIEncoding.GetEncoder" />
</Docs>
</Member>
<MemberGroup MemberName="GetBytes">
<AssemblyInfo>
<AssemblyName>System.Text.Encoding.Extensions</AssemblyName>
<AssemblyVersion>4.0.10.0</AssemblyVersion>
<AssemblyVersion>4.1.0.0</AssemblyVersion>
</AssemblyInfo>
<Docs>
<summary>Encodes a set of characters into a sequence of bytes.</summary>
</Docs>
</MemberGroup>
<Member MemberName="GetBytes">
<MemberSignature Language="C#" Value="public override int GetBytes (ReadOnlySpan<char> chars, Span<byte> bytes);" />
<MemberSignature Language="ILAsm" Value=".method public hidebysig virtual instance int32 GetBytes(valuetype System.ReadOnlySpan`1<char> chars, valuetype System.Span`1<unsigned int8> bytes) cil managed" />
<MemberSignature Language="DocId" Value="M:System.Text.ASCIIEncoding.GetBytes(System.ReadOnlySpan{System.Char},System.Span{System.Byte})" />
<MemberSignature Language="VB.NET" Value="Public Overrides Function GetBytes (chars As ReadOnlySpan(Of Char), bytes As Span(Of Byte)) As Integer" />
<MemberSignature Language="F#" Value="override this.GetBytes : ReadOnlySpan<char> * Span<byte> -> int" Usage="aSCIIEncoding.GetBytes (chars, bytes)" />
<MemberSignature Language="C++ CLI" Value="public:
 override int GetBytes(ReadOnlySpan<char> chars, Span<System::Byte> bytes);" />
<MemberType>Method</MemberType>
<AssemblyInfo>
<AssemblyName>System.Text.Encoding.Extensions</AssemblyName>
<AssemblyVersion>4.1.1.0</AssemblyVersion>
<AssemblyVersion>4.1.2.0</AssemblyVersion>
<AssemblyVersion>5.0.0.0</AssemblyVersion>
<AssemblyVersion>6.0.0.0</AssemblyVersion>
<AssemblyVersion>7.0.0.0</AssemblyVersion>
<AssemblyVersion>8.0.0.0</AssemblyVersion>
<AssemblyVersion>9.0.0.0</AssemblyVersion>
<AssemblyVersion>10.0.0.0</AssemblyVersion>
<AssemblyVersion>11.0.0.0</AssemblyVersion>
</AssemblyInfo>
<AssemblyInfo>
<AssemblyName>mscorlib</AssemblyName>
</AssemblyInfo>
<AssemblyInfo>
<AssemblyName>netstandard</AssemblyName>
</AssemblyInfo>
<ReturnValue>
<ReturnType>System.Int32</ReturnType>
</ReturnValue>
<Parameters>
<Parameter Name="chars" Type="System.ReadOnlySpan<System.Char>" Index="0" FrameworkAlternate="netcore-3.0;netcore-3.1;net-5.0;net-6.0;net-7.0;net-8.0;net-9.0;net-10.0;net-11.0" />
<Parameter Name="bytes" Type="System.Span<System.Byte>" Index="1" FrameworkAlternate="netcore-3.0;netcore-3.1;net-5.0;net-6.0;net-7.0;net-8.0;net-9.0;net-10.0;net-11.0" />
</Parameters>
<Docs>
<param name="chars">The character span to encode.</param>
<param name="bytes">The span to contain the resulting set of bytes.</param>
<summary>Encodes the specified character span into the specified byte span.</summary>
<returns>The actual number of bytes written into <paramref name="bytes" />.</returns>
<remarks>
<format type="text/markdown"><![CDATA[
## Remarks
To calculate the exact size required by <xref:System.Text.ASCIIEncoding.GetBytes%2A> to store the resulting bytes, use <xref:System.Text.ASCIIEncoding.GetByteCount%2A>. To calculate the maximum size, use <xref:System.Text.ASCIIEncoding.GetMaxByteCount%2A>. The <xref:System.Text.ASCIIEncoding.GetByteCount%2A> method generally allows allocation of less memory, while the <xref:System.Text.ASCIIEncoding.GetMaxByteCount%2A> method generally executes faster.
Data to be converted, such as data read from a stream, can be available only in sequential blocks. In this case, or if the amount of data is so large that it needs to be divided into smaller blocks, use the <xref:System.Text.Decoder> or the <xref:System.Text.Encoder> provided by the <xref:System.Text.ASCIIEncoding.GetDecoder%2A> method or the <xref:System.Text.ASCIIEncoding.GetEncoder%2A> method, respectively.
<xref:System.Text.ASCIIEncoding> does not provide error detection. Any Unicode character greater than `U+007F` is encoded as the ASCII question mark ("?").
> [!CAUTION]
> For security reasons, you should use <xref:System.Text.UTF8Encoding>, <xref:System.Text.UnicodeEncoding>, or <xref:System.Text.UTF32Encoding> and enable error detection.
]]></format>
</remarks>
</Docs>
</Member>
<Member MemberName="GetBytes">
<MemberSignature Language="C#" Value="public override int GetBytes (char* chars, int charCount, byte* bytes, int byteCount);" />
<MemberSignature Language="ILAsm" Value=".method public hidebysig virtual instance int32 GetBytes(char* chars, int32 charCount, unsigned int8* bytes, int32 byteCount) cil managed" />
<MemberSignature Language="DocId" Value="M:System.Text.ASCIIEncoding.GetBytes(System.Char*,System.Int32,System.Byte*,System.Int32)" />
<MemberSignature Language="F#" Value="override this.GetBytes : nativeptr<char> * int * nativeptr<byte> * int -> int" Usage="aSCIIEncoding.GetBytes (chars, charCount, bytes, byteCount)" />
<MemberSignature Language="C++ CLI" Value="public:
 override int GetBytes(char* chars, int charCount, System::Byte* bytes, int byteCount);" />
<MemberType>Method</MemberType>
<AssemblyInfo>
<AssemblyName>System.Text.Encoding.Extensions</AssemblyName>
<AssemblyVersion>4.0.10.0</AssemblyVersion>
<AssemblyVersion>4.1.0.0</AssemblyVersion>
<AssemblyVersion>4.1.1.0</AssemblyVersion>
<AssemblyVersion>4.1.2.0</AssemblyVersion>
<AssemblyVersion>5.0.0.0</AssemblyVersion>
<AssemblyVersion>6.0.0.0</AssemblyVersion>
<AssemblyVersion>7.0.0.0</AssemblyVersion>
<AssemblyVersion>8.0.0.0</AssemblyVersion>
<AssemblyVersion>9.0.0.0</AssemblyVersion>
<AssemblyVersion>10.0.0.0</AssemblyVersion>
<AssemblyVersion>11.0.0.0</AssemblyVersion>
</AssemblyInfo>
<AssemblyInfo>
<AssemblyName>mscorlib</AssemblyName>
<AssemblyVersion>2.0.0.0</AssemblyVersion>
<AssemblyVersion>2.0.5.0</AssemblyVersion>
<AssemblyVersion>4.0.0.0</AssemblyVersion>
</AssemblyInfo>
<AssemblyInfo>
<AssemblyName>netstandard</AssemblyName>
<AssemblyVersion>2.0.0.0</AssemblyVersion>
<AssemblyVersion>2.1.0.0</AssemblyVersion>
</AssemblyInfo>
<Attributes>
<Attribute FrameworkAlternate="dotnet-uwp-10.0;net-10.0;net-11.0;net-5.0;net-6.0;net-7.0;net-8.0;net-9.0;netcore-1.0;netcore-1.1;netcore-2.0;netcore-2.1;netcore-2.2;netcore-3.0;netcore-3.1;netframework-2.0;netframework-3.0;netframework-3.5;netframework-4.0;netframework-4.5;netframework-4.5.1;netframework-4.5.2;netframework-4.6;netframework-4.6.1;netframework-4.6.2;netframework-4.7;netframework-4.7.1;netframework-4.7.2;netframework-4.8;netframework-4.8.1;netstandard-1.3;netstandard-1.4;netstandard-1.6;netstandard-2.0;netstandard-2.1">
<AttributeName Language="C#">[System.CLSCompliant(false)]</AttributeName>
<AttributeName Language="F#">[<System.CLSCompliant(false)>]</AttributeName>
</Attribute>
<Attribute FrameworkAlternate="dotnet-uwp-10.0;netcore-1.0;netcore-1.1;netcore-2.0;netframework-4.0;netframework-4.5;netframework-4.5.1;netframework-4.5.2;netframework-4.6;netframework-4.6.1;netframework-4.6.2;netframework-4.7;netframework-4.7.1;netframework-4.7.2;netframework-4.8;netframework-4.8.1;netstandard-1.3;netstandard-1.4;netstandard-1.6">
<AttributeName Language="C#">[System.Security.SecurityCritical]</AttributeName>
<AttributeName Language="F#">[<System.Security.SecurityCritical>]</AttributeName>
</Attribute>
<Attribute FrameworkAlternate="netframework-2.0;netframework-3.0;netframework-3.5;netframework-4.0;netframework-4.5;netframework-4.5.1;netframework-4.5.2;netframework-4.6;netframework-4.6.1;netframework-4.6.2;netframework-4.7;netframework-4.7.1;netframework-4.7.2;netframework-4.8;netframework-4.8.1">
<AttributeName Language="C#">[System.Runtime.InteropServices.ComVisible(false)]</AttributeName>
<AttributeName Language="F#">[<System.Runtime.InteropServices.ComVisible(false)>]</AttributeName>
</Attribute>
</Attributes>
<ReturnValue>
<ReturnType>System.Int32</ReturnType>
</ReturnValue>
<Parameters>
<Parameter Name="chars" Type="System.Char*" Index="0" FrameworkAlternate="dotnet-uwp-10.0;net-10.0;net-11.0;net-5.0;net-6.0;net-7.0;net-8.0;net-9.0;netcore-1.0;netcore-1.1;netcore-2.0;netcore-2.1;netcore-2.2;netcore-3.0;netcore-3.1;netframework-2.0;netframework-3.0;netframework-3.5;netframework-4.0;netframework-4.5;netframework-4.5.1;netframework-4.5.2;netframework-4.6;netframework-4.6.1;netframework-4.6.2;netframework-4.7;netframework-4.7.1;netframework-4.7.2;netframework-4.8;netframework-4.8.1;netstandard-1.3;netstandard-1.4;netstandard-1.6;netstandard-2.0;netstandard-2.1" />
<Parameter Name="charCount" Type="System.Int32" Index="1" FrameworkAlternate="dotnet-uwp-10.0;net-10.0;net-11.0;net-5.0;net-6.0;net-7.0;net-8.0;net-9.0;netcore-1.0;netcore-1.1;netcore-2.0;netcore-2.1;netcore-2.2;netcore-3.0;netcore-3.1;netframework-2.0;netframework-3.0;netframework-3.5;netframework-4.0;netframework-4.5;netframework-4.5.1;netframework-4.5.2;netframework-4.6;netframework-4.6.1;netframework-4.6.2;netframework-4.7;netframework-4.7.1;netframework-4.7.2;netframework-4.8;netframework-4.8.1;netstandard-1.3;netstandard-1.4;netstandard-1.6;netstandard-2.0;netstandard-2.1" />
<Parameter Name="bytes" Type="System.Byte*" Index="2" FrameworkAlternate="dotnet-uwp-10.0;net-10.0;net-11.0;net-5.0;net-6.0;net-7.0;net-8.0;net-9.0;netcore-1.0;netcore-1.1;netcore-2.0;netcore-2.1;netcore-2.2;netcore-3.0;netcore-3.1;netframework-2.0;netframework-3.0;netframework-3.5;netframework-4.0;netframework-4.5;netframework-4.5.1;netframework-4.5.2;netframework-4.6;netframework-4.6.1;netframework-4.6.2;netframework-4.7;netframework-4.7.1;netframework-4.7.2;netframework-4.8;netframework-4.8.1;netstandard-1.3;netstandard-1.4;netstandard-1.6;netstandard-2.0;netstandard-2.1" />
<Parameter Name="byteCount" Type="System.Int32" Index="3" FrameworkAlternate="dotnet-uwp-10.0;net-10.0;net-11.0;net-5.0;net-6.0;net-7.0;net-8.0;net-9.0;netcore-1.0;netcore-1.1;netcore-2.0;netcore-2.1;netcore-2.2;netcore-3.0;netcore-3.1;netframework-2.0;netframework-3.0;netframework-3.5;netframework-4.0;netframework-4.5;netframework-4.5.1;netframework-4.5.2;netframework-4.6;netframework-4.6.1;netframework-4.6.2;netframework-4.7;netframework-4.7.1;netframework-4.7.2;netframework-4.8;netframework-4.8.1;netstandard-1.3;netstandard-1.4;netstandard-1.6;netstandard-2.0;netstandard-2.1" />
</Parameters>
<Docs>
<param name="chars">A pointer to the first character to encode.</param>
<param name="charCount">The number of characters to encode.</param>
<param name="bytes">A pointer to the location at which to start writing the resulting sequence of bytes.</param>
<param name="byteCount">The maximum number of bytes to write.</param>
<summary>Encodes a set of characters starting at the specified character pointer into a sequence of bytes that are stored starting at the specified byte pointer.</summary>
<returns>The actual number of bytes written at the location indicated by <paramref name="bytes" />.</returns>
<remarks>
<format type="text/markdown"><![CDATA[
## Remarks
To calculate the exact array size required by <xref:System.Text.ASCIIEncoding.GetBytes%2A> to store the resulting bytes, the application uses <xref:System.Text.ASCIIEncoding.GetByteCount%2A>. To calculate the maximum array size, the application should use <xref:System.Text.ASCIIEncoding.GetMaxByteCount%2A>. The <xref:System.Text.ASCIIEncoding.GetByteCount%2A> method generally allows allocation of less memory, while the <xref:System.Text.ASCIIEncoding.GetMaxByteCount%2A> method generally executes faster.
Data to be converted, such as data read from a stream, can be available only in sequential blocks. In this case, or if the amount of data is so large that it needs to be divided into smaller blocks, the application should use the <xref:System.Text.Decoder> or the <xref:System.Text.Encoder> provided by the <xref:System.Text.ASCIIEncoding.GetDecoder%2A> method or the <xref:System.Text.ASCIIEncoding.GetEncoder%2A> method, respectively.
<xref:System.Text.ASCIIEncoding> does not provide error detection. Any Unicode character greater than U+007F is translated to an ASCII question mark ("?").
> [!CAUTION]
> For security reasons, your application is recommended to use <xref:System.Text.UTF8Encoding>, <xref:System.Text.UnicodeEncoding>, or <xref:System.Text.UTF32Encoding> and enable error detection.
]]></format>
</remarks>
<altCompliant cref="M:System.Text.ASCIIEncoding.GetBytes(System.Char[],System.Int32,System.Int32,System.Byte[],System.Int32)" />
<exception cref="T:System.ArgumentNullException">
<paramref name="chars" /> is <see langword="null" />.
-or-
<paramref name="bytes" /> is <see langword="null" />.</exception>
<exception cref="T:System.ArgumentOutOfRangeException">
<paramref name="charCount" /> or <paramref name="byteCount" /> is less than zero.</exception>
<exception cref="T:System.ArgumentException">
<paramref name="byteCount" /> is less than the resulting number of bytes.</exception>
<exception cref="T:System.Text.EncoderFallbackException">A fallback occurred (for more information, see <see href="https://learn.microsoft.com/dotnet/standard/base-types/character-encoding">Character Encoding in .NET</see>)
-and-
<see cref="P:System.Text.Encoding.EncoderFallback" /> is set to <see cref="T:System.Text.EncoderExceptionFallback" />.</exception>
<altmember cref="M:System.Text.ASCIIEncoding.GetEncoder" />
<altmember cref="M:System.Text.ASCIIEncoding.GetByteCount(System.Char[],System.Int32,System.Int32)" />
<altmember cref="M:System.Text.ASCIIEncoding.GetMaxByteCount(System.Int32)" />
</Docs>
</Member>
<Member MemberName="GetBytes">
<MemberSignature Language="C#" Value="public override int GetBytes (char[] chars, int charIndex, int charCount, byte[] bytes, int byteIndex);" />
<MemberSignature Language="ILAsm" Value=".method public hidebysig virtual instance int32 GetBytes(char[] chars, int32 charIndex, int32 charCount, unsigned int8[] bytes, int32 byteIndex) cil managed" />
<MemberSignature Language="DocId" Value="M:System.Text.ASCIIEncoding.GetBytes(System.Char[],System.Int32,System.Int32,System.Byte[],System.Int32)" />
<MemberSignature Language="VB.NET" Value="Public Overrides Function GetBytes (chars As Char(), charIndex As Integer, charCount As Integer, bytes As Byte(), byteIndex As Integer) As Integer" />
<MemberSignature Language="F#" Value="override this.GetBytes : char[] * int * int * byte[] * int -> int" Usage="aSCIIEncoding.GetBytes (chars, charIndex, charCount, bytes, byteIndex)" />
<MemberSignature Language="C++ CLI" Value="public:
 override int GetBytes(cli::array <char> ^ chars, int charIndex, int charCount, cli::array <System::Byte> ^ bytes, int byteIndex);" />
<MemberType>Method</MemberType>
<AssemblyInfo>
<AssemblyName>System.Text.Encoding.Extensions</AssemblyName>
<AssemblyVersion>4.0.10.0</AssemblyVersion>
<AssemblyVersion>4.1.0.0</AssemblyVersion>
<AssemblyVersion>4.1.1.0</AssemblyVersion>
<AssemblyVersion>4.1.2.0</AssemblyVersion>
<AssemblyVersion>5.0.0.0</AssemblyVersion>
<AssemblyVersion>6.0.0.0</AssemblyVersion>
<AssemblyVersion>7.0.0.0</AssemblyVersion>
<AssemblyVersion>8.0.0.0</AssemblyVersion>
<AssemblyVersion>9.0.0.0</AssemblyVersion>
<AssemblyVersion>10.0.0.0</AssemblyVersion>
<AssemblyVersion>11.0.0.0</AssemblyVersion>
</AssemblyInfo>
<AssemblyInfo>
<AssemblyName>mscorlib</AssemblyName>
<AssemblyVersion>1.0.5000.0</AssemblyVersion>
<AssemblyVersion>2.0.0.0</AssemblyVersion>
<AssemblyVersion>2.0.5.0</AssemblyVersion>
<AssemblyVersion>4.0.0.0</AssemblyVersion>
</AssemblyInfo>
<AssemblyInfo>
<AssemblyName>netstandard</AssemblyName>
<AssemblyVersion>2.0.0.0</AssemblyVersion>
<AssemblyVersion>2.1.0.0</AssemblyVersion>
</AssemblyInfo>
<Attributes>
<Attribute FrameworkAlternate="netframework-4.0;netframework-4.5;netframework-4.5.1;netframework-4.5.2;netframework-4.6;netframework-4.6.1;netframework-4.6.2;netframework-4.7;netframework-4.7.1;netframework-4.7.2;netframework-4.8;netframework-4.8.1">
<AttributeName Language="C#">[System.Security.SecuritySafeCritical]</AttributeName>
<AttributeName Language="F#">[<System.Security.SecuritySafeCritical>]</AttributeName>
</Attribute>
</Attributes>
<ReturnValue>
<ReturnType>System.Int32</ReturnType>
</ReturnValue>
<Parameters>
<Parameter Name="chars" Type="System.Char[]" />
<Parameter Name="charIndex" Type="System.Int32" />
<Parameter Name="charCount" Type="System.Int32" />
<Parameter Name="bytes" Type="System.Byte[]" />
<Parameter Name="byteIndex" Type="System.Int32" />
</Parameters>
<Docs>
<param name="chars">The character array containing the set of characters to encode.</param>
<param name="charIndex">The index of the first character to encode.</param>
<param name="charCount">The number of characters to encode.</param>
<param name="bytes">The byte array to contain the resulting sequence of bytes.</param>
<param name="byteIndex">The index at which to start writing the resulting sequence of bytes.</param>
<summary>Encodes a set of characters from the specified character array into the specified byte array.</summary>
<returns>The actual number of bytes written into <paramref name="bytes" />.</returns>
<remarks>
<format type="text/markdown"><![CDATA[
## Remarks
To calculate the exact array size required by <xref:System.Text.ASCIIEncoding.GetBytes%2A> to store the resulting bytes, the application uses <xref:System.Text.ASCIIEncoding.GetByteCount%2A>. To calculate the maximum array size, the application should use <xref:System.Text.ASCIIEncoding.GetMaxByteCount%2A>. The <xref:System.Text.ASCIIEncoding.GetByteCount%2A> method generally allows allocation of less memory, while the <xref:System.Text.ASCIIEncoding.GetMaxByteCount%2A> method generally executes faster.
Data to be converted, such as data read from a stream, can be available only in sequential blocks. In this case, or if the amount of data is so large that it needs to be divided into smaller blocks, the application should use the <xref:System.Text.Decoder> or the <xref:System.Text.Encoder> provided by the <xref:System.Text.ASCIIEncoding.GetDecoder%2A> method or the <xref:System.Text.ASCIIEncoding.GetEncoder%2A> method, respectively.
<xref:System.Text.ASCIIEncoding> does not provide error detection. Any Unicode character greater than U+007F is encoded as the ASCII question mark ("?").
> [!CAUTION]
> For security reasons, your application is recommended to use <xref:System.Text.UTF8Encoding>, <xref:System.Text.UnicodeEncoding>, or <xref:System.Text.UTF32Encoding> and enable error detection.
## Examples
The following example demonstrates how to use the <xref:System.Text.ASCIIEncoding.GetBytes%2A> method to encode a range of characters from a string and store the encoded characters in a range of elements in a byte array.
:::code language="csharp" source="~/snippets/csharp/System.Text/ASCIIEncoding/GetBytes/getbytes-string-int32-int32-byte[]-int32.cs" id="Snippet1":::
:::code language="vb" source="~/snippets/visualbasic/System.Text/ASCIIEncoding/GetBytes/getbytes-string-int32-int32-byte[]-int32.vb" id="Snippet1":::
]]></format>
</remarks>
<exception cref="T:System.ArgumentNullException">
<paramref name="chars" /> is <see langword="null" />.
-or-
<paramref name="bytes" /> is <see langword="null" />.</exception>
<exception cref="T:System.ArgumentOutOfRangeException">
<paramref name="charIndex" /> or <paramref name="charCount" /> or <paramref name="byteIndex" /> is less than zero.
-or-
<paramref name="charIndex" /> and <paramref name="charCount" /> do not denote a valid range in <paramref name="chars" />.
-or-
<paramref name="byteIndex" /> is not a valid index in <paramref name="bytes" />.</exception>
<exception cref="T:System.ArgumentException">
<paramref name="bytes" /> does not have enough capacity from <paramref name="byteIndex" /> to the end of the array to accommodate the resulting bytes.</exception>
<exception cref="T:System.Text.EncoderFallbackException">A fallback occurred (for more information, see <see href="https://learn.microsoft.com/dotnet/standard/base-types/character-encoding">Character Encoding in .NET</see>)
-and-
<see cref="P:System.Text.Encoding.EncoderFallback" /> is set to <see cref="T:System.Text.EncoderExceptionFallback" />.</exception>
<altmember cref="M:System.Text.ASCIIEncoding.GetEncoder" />
<altmember cref="M:System.Text.ASCIIEncoding.GetByteCount(System.Char[],System.Int32,System.Int32)" />
<altmember cref="M:System.Text.ASCIIEncoding.GetMaxByteCount(System.Int32)" />
</Docs>
</Member>
<Member MemberName="GetBytes">
<MemberSignature Language="C#" Value="public override int GetBytes (string chars, int charIndex, int charCount, byte[] bytes, int byteIndex);" />
<MemberSignature Language="ILAsm" Value=".method public hidebysig virtual instance int32 GetBytes(string chars, int32 charIndex, int32 charCount, unsigned int8[] bytes, int32 byteIndex) cil managed" />
<MemberSignature Language="DocId" Value="M:System.Text.ASCIIEncoding.GetBytes(System.String,System.Int32,System.Int32,System.Byte[],System.Int32)" />
<MemberSignature Language="VB.NET" Value="Public Overrides Function GetBytes (chars As String, charIndex As Integer, charCount As Integer, bytes As Byte(), byteIndex As Integer) As Integer" />
<MemberSignature Language="F#" Value="override this.GetBytes : string * int * int * byte[] * int -> int" Usage="aSCIIEncoding.GetBytes (chars, charIndex, charCount, bytes, byteIndex)" />
<MemberSignature Language="C++ CLI" Value="public:
 override int GetBytes(System::String ^ chars, int charIndex, int charCount, cli::array <System::Byte> ^ bytes, int byteIndex);" />
<MemberType>Method</MemberType>
<AssemblyInfo>
<AssemblyName>System.Text.Encoding.Extensions</AssemblyName>
<AssemblyVersion>4.0.10.0</AssemblyVersion>
<AssemblyVersion>4.1.0.0</AssemblyVersion>
<AssemblyVersion>4.1.1.0</AssemblyVersion>
<AssemblyVersion>4.1.2.0</AssemblyVersion>
<AssemblyVersion>5.0.0.0</AssemblyVersion>
<AssemblyVersion>6.0.0.0</AssemblyVersion>
<AssemblyVersion>7.0.0.0</AssemblyVersion>
<AssemblyVersion>8.0.0.0</AssemblyVersion>
<AssemblyVersion>9.0.0.0</AssemblyVersion>
<AssemblyVersion>10.0.0.0</AssemblyVersion>
<AssemblyVersion>11.0.0.0</AssemblyVersion>
</AssemblyInfo>
<AssemblyInfo>
<AssemblyName>mscorlib</AssemblyName>
<AssemblyVersion>1.0.5000.0</AssemblyVersion>
<AssemblyVersion>2.0.0.0</AssemblyVersion>
<AssemblyVersion>2.0.5.0</AssemblyVersion>
<AssemblyVersion>4.0.0.0</AssemblyVersion>
</AssemblyInfo>
<AssemblyInfo>
<AssemblyName>netstandard</AssemblyName>
<AssemblyVersion>2.0.0.0</AssemblyVersion>
<AssemblyVersion>2.1.0.0</AssemblyVersion>
</AssemblyInfo>
<Attributes>
<Attribute FrameworkAlternate="netframework-4.0;netframework-4.5;netframework-4.5.1;netframework-4.5.2;netframework-4.6;netframework-4.6.1;netframework-4.6.2;netframework-4.7;netframework-4.7.1;netframework-4.7.2;netframework-4.8;netframework-4.8.1">
<AttributeName Language="C#">[System.Security.SecuritySafeCritical]</AttributeName>
<AttributeName Language="F#">[<System.Security.SecuritySafeCritical>]</AttributeName>
</Attribute>
</Attributes>
<ReturnValue>
<ReturnType>System.Int32</ReturnType>
</ReturnValue>
<Parameters>
<Parameter Name="chars" Type="System.String" />
<Parameter Name="charIndex" Type="System.Int32" />
<Parameter Name="charCount" Type="System.Int32" />
<Parameter Name="bytes" Type="System.Byte[]" />
<Parameter Name="byteIndex" Type="System.Int32" />
</Parameters>
<Docs>
<param name="chars">The set of characters to encode.</param>
<param name="charIndex">The index of the first character to encode.</param>
<param name="charCount">The number of characters to encode.</param>
<param name="bytes">The byte array to contain the resulting sequence of bytes.</param>
<param name="byteIndex">The index at which to start writing the resulting sequence of bytes.</param>
<summary>Encodes a set of characters from the specified <see cref="T:System.String" /> into the specified byte array.</summary>
<returns>The actual number of bytes written into <paramref name="bytes" />.</returns>
<remarks>
<format type="text/markdown"><![CDATA[
## Remarks
To calculate the exact array size required by <xref:System.Text.ASCIIEncoding.GetBytes%2A> to store the resulting bytes, the application uses <xref:System.Text.ASCIIEncoding.GetByteCount%2A>. To calculate the maximum array size, the application should use <xref:System.Text.ASCIIEncoding.GetMaxByteCount%2A>. The <xref:System.Text.ASCIIEncoding.GetByteCount%2A> method generally allows allocation of less memory, while the <xref:System.Text.ASCIIEncoding.GetMaxByteCount%2A> method generally executes faster.
Data to be converted, such as data read from a stream, can be available only in sequential blocks. In this case, or if the amount of data is so large that it needs to be divided into smaller blocks, the application should use the <xref:System.Text.Decoder> or the <xref:System.Text.Encoder> provided by the <xref:System.Text.ASCIIEncoding.GetDecoder%2A> method or the <xref:System.Text.ASCIIEncoding.GetEncoder%2A> method, respectively.
<xref:System.Text.ASCIIEncoding> does not provide error detection. Any Unicode character greater than U+007F is encoded as the ASCII question mark ("?").
> [!CAUTION]
> For security reasons, it's recommended to use <xref:System.Text.UTF8Encoding>, <xref:System.Text.UnicodeEncoding>, or <xref:System.Text.UTF32Encoding> and enable error detection.
## Examples
The following example demonstrates how to use the <xref:System.Text.ASCIIEncoding.GetBytes%2A> method to encode a range of elements from a Unicode character array and store the encoded bytes in a range of elements in a byte array.
:::code language="csharp" source="~/snippets/csharp/System.Text/ASCIIEncoding/GetBytes/getbytes-char[]-int32-int32-byte[]-int32.cs" id="Snippet1":::
:::code language="vb" source="~/snippets/visualbasic/System.Text/ASCIIEncoding/GetBytes/getbytes-char[]-int32-int32-byte[]-int32.vb" id="Snippet1":::
]]></format>
</remarks>
<exception cref="T:System.ArgumentNullException">
<paramref name="chars" /> or <paramref name="bytes" /> is <see langword="null" />.</exception>
<exception cref="T:System.ArgumentOutOfRangeException">
<paramref name="charIndex" /> or <paramref name="charCount" /> or <paramref name="byteIndex" /> is less than zero.
-or-
<paramref name="charIndex" /> and <paramref name="charCount" /> do not denote a valid range in <paramref name="chars" />.
-or-
<paramref name="byteIndex" /> is not a valid index in <paramref name="bytes" />.</exception>
<exception cref="T:System.ArgumentException">
<paramref name="bytes" /> does not have enough capacity from <paramref name="byteIndex" /> to the end of the array to accommodate the resulting bytes.</exception>
<exception cref="T:System.Text.EncoderFallbackException">A fallback occurred (for more information, see <see href="https://learn.microsoft.com/dotnet/standard/base-types/character-encoding">Character Encoding in .NET</see>)
-and-
<see cref="P:System.Text.Encoding.EncoderFallback" /> is set to <see cref="T:System.Text.EncoderExceptionFallback" />.</exception>
<altmember cref="M:System.Text.ASCIIEncoding.GetEncoder" />
<altmember cref="M:System.Text.ASCIIEncoding.GetByteCount(System.Char[],System.Int32,System.Int32)" />
<altmember cref="M:System.Text.ASCIIEncoding.GetMaxByteCount(System.Int32)" />
</Docs>
</Member>
<MemberGroup MemberName="GetCharCount">
<AssemblyInfo>
<AssemblyName>System.Text.Encoding.Extensions</AssemblyName>
<AssemblyVersion>4.0.10.0</AssemblyVersion>
<AssemblyVersion>4.1.0.0</AssemblyVersion>
</AssemblyInfo>
<Docs>
<summary>Calculates the number of characters produced by decoding a sequence of bytes.</summary>
</Docs>
</MemberGroup>
<Member MemberName="GetCharCount">
<MemberSignature Language="C#" Value="public override int GetCharCount (ReadOnlySpan<byte> bytes);" />
<MemberSignature Language="ILAsm" Value=".method public hidebysig virtual instance int32 GetCharCount(valuetype System.ReadOnlySpan`1<unsigned int8> bytes) cil managed" />
<MemberSignature Language="DocId" Value="M:System.Text.ASCIIEncoding.GetCharCount(System.ReadOnlySpan{System.Byte})" />
<MemberSignature Language="VB.NET" Value="Public Overrides Function GetCharCount (bytes As ReadOnlySpan(Of Byte)) As Integer" />
<MemberSignature Language="F#" Value="override this.GetCharCount : ReadOnlySpan<byte> -> int" Usage="aSCIIEncoding.GetCharCount bytes" />
<MemberSignature Language="C++ CLI" Value="public:
 override int GetCharCount(ReadOnlySpan<System::Byte> bytes);" />
<MemberType>Method</MemberType>
<AssemblyInfo>
<AssemblyName>System.Text.Encoding.Extensions</AssemblyName>
<AssemblyVersion>4.1.1.0</AssemblyVersion>
<AssemblyVersion>4.1.2.0</AssemblyVersion>
<AssemblyVersion>5.0.0.0</AssemblyVersion>
<AssemblyVersion>6.0.0.0</AssemblyVersion>
<AssemblyVersion>7.0.0.0</AssemblyVersion>
<AssemblyVersion>8.0.0.0</AssemblyVersion>
<AssemblyVersion>9.0.0.0</AssemblyVersion>
<AssemblyVersion>10.0.0.0</AssemblyVersion>
<AssemblyVersion>11.0.0.0</AssemblyVersion>
</AssemblyInfo>
<AssemblyInfo>
<AssemblyName>mscorlib</AssemblyName>
</AssemblyInfo>
<AssemblyInfo>
<AssemblyName>netstandard</AssemblyName>
</AssemblyInfo>
<ReturnValue>
<ReturnType>System.Int32</ReturnType>
</ReturnValue>
<Parameters>
<Parameter Name="bytes" Type="System.ReadOnlySpan<System.Byte>" Index="0" FrameworkAlternate="netcore-3.0;netcore-3.1;net-5.0;net-6.0;net-7.0;net-8.0;net-9.0;net-10.0;net-11.0" />
</Parameters>
<Docs>
<param name="bytes">The span containing the set of bytes to decode.</param>
<summary>Calculates the number of characters produced by decoding the specified byte span.</summary>
<returns>The number of characters produced by decoding the specified byte span.</returns>
<remarks>
<format type="text/markdown"><![CDATA[
## Remarks
To calculate the exact size required by <xref:System.Text.ASCIIEncoding.GetChars%2A> to store the resulting characters, use <xref:System.Text.ASCIIEncoding.GetCharCount%2A>. To calculate the maximum size, use <xref:System.Text.ASCIIEncoding.GetMaxCharCount%2A>. The <xref:System.Text.ASCIIEncoding.GetCharCount%2A> method generally allows allocation of less memory, while the <xref:System.Text.ASCIIEncoding.GetMaxCharCount%2A> method generally executes faster.
]]></format>
</remarks>
</Docs>
</Member>
<Member MemberName="GetCharCount">
<MemberSignature Language="C#" Value="public override int GetCharCount (byte* bytes, int count);" />
<MemberSignature Language="ILAsm" Value=".method public hidebysig virtual instance int32 GetCharCount(unsigned int8* bytes, int32 count) cil managed" />
<MemberSignature Language="DocId" Value="M:System.Text.ASCIIEncoding.GetCharCount(System.Byte*,System.Int32)" />
<MemberSignature Language="F#" Value="override this.GetCharCount : nativeptr<byte> * int -> int" Usage="aSCIIEncoding.GetCharCount (bytes, count)" />
<MemberSignature Language="C++ CLI" Value="public:
 override int GetCharCount(System::Byte* bytes, int count);" />
<MemberType>Method</MemberType>
<AssemblyInfo>
<AssemblyName>System.Text.Encoding.Extensions</AssemblyName>
<AssemblyVersion>4.0.10.0</AssemblyVersion>
<AssemblyVersion>4.1.0.0</AssemblyVersion>
<AssemblyVersion>4.1.1.0</AssemblyVersion>
<AssemblyVersion>4.1.2.0</AssemblyVersion>
<AssemblyVersion>5.0.0.0</AssemblyVersion>
<AssemblyVersion>6.0.0.0</AssemblyVersion>
<AssemblyVersion>7.0.0.0</AssemblyVersion>
<AssemblyVersion>8.0.0.0</AssemblyVersion>
<AssemblyVersion>9.0.0.0</AssemblyVersion>
<AssemblyVersion>10.0.0.0</AssemblyVersion>
<AssemblyVersion>11.0.0.0</AssemblyVersion>
</AssemblyInfo>
<AssemblyInfo>
<AssemblyName>mscorlib</AssemblyName>
<AssemblyVersion>2.0.0.0</AssemblyVersion>
<AssemblyVersion>2.0.5.0</AssemblyVersion>
<AssemblyVersion>4.0.0.0</AssemblyVersion>
</AssemblyInfo>
<AssemblyInfo>
<AssemblyName>netstandard</AssemblyName>
<AssemblyVersion>2.0.0.0</AssemblyVersion>
<AssemblyVersion>2.1.0.0</AssemblyVersion>
</AssemblyInfo>
<Attributes>
<Attribute FrameworkAlternate="dotnet-uwp-10.0;net-10.0;net-11.0;net-5.0;net-6.0;net-7.0;net-8.0;net-9.0;netcore-1.0;netcore-1.1;netcore-2.0;netcore-2.1;netcore-2.2;netcore-3.0;netcore-3.1;netframework-2.0;netframework-3.0;netframework-3.5;netframework-4.0;netframework-4.5;netframework-4.5.1;netframework-4.5.2;netframework-4.6;netframework-4.6.1;netframework-4.6.2;netframework-4.7;netframework-4.7.1;netframework-4.7.2;netframework-4.8;netframework-4.8.1;netstandard-1.3;netstandard-1.4;netstandard-1.6;netstandard-2.0;netstandard-2.1">
<AttributeName Language="C#">[System.CLSCompliant(false)]</AttributeName>
<AttributeName Language="F#">[<System.CLSCompliant(false)>]</AttributeName>
</Attribute>
<Attribute FrameworkAlternate="dotnet-uwp-10.0;netcore-1.0;netcore-1.1;netcore-2.0;netframework-4.0;netframework-4.5;netframework-4.5.1;netframework-4.5.2;netframework-4.6;netframework-4.6.1;netframework-4.6.2;netframework-4.7;netframework-4.7.1;netframework-4.7.2;netframework-4.8;netframework-4.8.1;netstandard-1.3;netstandard-1.4;netstandard-1.6">
<AttributeName Language="C#">[System.Security.SecurityCritical]</AttributeName>
<AttributeName Language="F#">[<System.Security.SecurityCritical>]</AttributeName>
</Attribute>
<Attribute FrameworkAlternate="netframework-2.0;netframework-3.0;netframework-3.5;netframework-4.0;netframework-4.5;netframework-4.5.1;netframework-4.5.2;netframework-4.6;netframework-4.6.1;netframework-4.6.2;netframework-4.7;netframework-4.7.1;netframework-4.7.2;netframework-4.8;netframework-4.8.1">
<AttributeName Language="C#">[System.Runtime.InteropServices.ComVisible(false)]</AttributeName>
<AttributeName Language="F#">[<System.Runtime.InteropServices.ComVisible(false)>]</AttributeName>
</Attribute>
</Attributes>
<ReturnValue>
<ReturnType>System.Int32</ReturnType>
</ReturnValue>
<Parameters>
<Parameter Name="bytes" Type="System.Byte*" Index="0" FrameworkAlternate="dotnet-uwp-10.0;net-10.0;net-11.0;net-5.0;net-6.0;net-7.0;net-8.0;net-9.0;netcore-1.0;netcore-1.1;netcore-2.0;netcore-2.1;netcore-2.2;netcore-3.0;netcore-3.1;netframework-2.0;netframework-3.0;netframework-3.5;netframework-4.0;netframework-4.5;netframework-4.5.1;netframework-4.5.2;netframework-4.6;netframework-4.6.1;netframework-4.6.2;netframework-4.7;netframework-4.7.1;netframework-4.7.2;netframework-4.8;netframework-4.8.1;netstandard-1.3;netstandard-1.4;netstandard-1.6;netstandard-2.0;netstandard-2.1" />
<Parameter Name="count" Type="System.Int32" Index="1" FrameworkAlternate="dotnet-uwp-10.0;net-10.0;net-11.0;net-5.0;net-6.0;net-7.0;net-8.0;net-9.0;netcore-1.0;netcore-1.1;netcore-2.0;netcore-2.1;netcore-2.2;netcore-3.0;netcore-3.1;netframework-2.0;netframework-3.0;netframework-3.5;netframework-4.0;netframework-4.5;netframework-4.5.1;netframework-4.5.2;netframework-4.6;netframework-4.6.1;netframework-4.6.2;netframework-4.7;netframework-4.7.1;netframework-4.7.2;netframework-4.8;netframework-4.8.1;netstandard-1.3;netstandard-1.4;netstandard-1.6;netstandard-2.0;netstandard-2.1" />
</Parameters>
<Docs>
<param name="bytes">A pointer to the first byte to decode.</param>
<param name="count">The number of bytes to decode.</param>
<summary>Calculates the number of characters produced by decoding a sequence of bytes starting at the specified byte pointer.</summary>
<returns>The number of characters produced by decoding the specified sequence of bytes.</returns>
<remarks>
<format type="text/markdown"><![CDATA[
## Remarks
To calculate the exact array size required by <xref:System.Text.ASCIIEncoding.GetChars%2A> to store the resulting characters, the application uses <xref:System.Text.ASCIIEncoding.GetCharCount%2A>. To calculate the maximum array size, the application should use <xref:System.Text.ASCIIEncoding.GetMaxCharCount%2A>. The <xref:System.Text.ASCIIEncoding.GetCharCount%2A> method generally allows allocation of less memory, while the <xref:System.Text.ASCIIEncoding.GetMaxCharCount%2A> method generally executes faster.
]]></format>
</remarks>
<altCompliant cref="M:System.Text.ASCIIEncoding.GetCharCount(System.Byte[],System.Int32,System.Int32)" />
<exception cref="T:System.ArgumentNullException">
<paramref name="bytes" /> is <see langword="null" />.</exception>
<exception cref="T:System.ArgumentOutOfRangeException">
<paramref name="count" /> is less than zero.
-or-
The resulting number of bytes is greater than the maximum number that can be returned as an integer.</exception>
<exception cref="T:System.Text.DecoderFallbackException">A fallback occurred (for more information, see <see href="https://learn.microsoft.com/dotnet/standard/base-types/character-encoding">Character Encoding in .NET</see>)
-and-
<see cref="P:System.Text.Encoding.DecoderFallback" /> is set to <see cref="T:System.Text.DecoderExceptionFallback" />.</exception>
<altmember cref="Overload:System.Text.ASCIIEncoding.GetChars" />
<altmember cref="M:System.Text.ASCIIEncoding.GetMaxCharCount(System.Int32)" />
<altmember cref="M:System.Text.ASCIIEncoding.GetDecoder" />
</Docs>
</Member>
<Member MemberName="GetCharCount">
<MemberSignature Language="C#" Value="public override int GetCharCount (byte[] bytes, int index, int count);" />
<MemberSignature Language="ILAsm" Value=".method public hidebysig virtual instance int32 GetCharCount(unsigned int8[] bytes, int32 index, int32 count) cil managed" />
<MemberSignature Language="DocId" Value="M:System.Text.ASCIIEncoding.GetCharCount(System.Byte[],System.Int32,System.Int32)" />
<MemberSignature Language="VB.NET" Value="Public Overrides Function GetCharCount (bytes As Byte(), index As Integer, count As Integer) As Integer" />
<MemberSignature Language="F#" Value="override this.GetCharCount : byte[] * int * int -> int" Usage="aSCIIEncoding.GetCharCount (bytes, index, count)" />
<MemberSignature Language="C++ CLI" Value="public:
 override int GetCharCount(cli::array <System::Byte> ^ bytes, int index, int count);" />
<MemberType>Method</MemberType>
<AssemblyInfo>
<AssemblyName>System.Text.Encoding.Extensions</AssemblyName>
<AssemblyVersion>4.0.10.0</AssemblyVersion>
<AssemblyVersion>4.1.0.0</AssemblyVersion>
<AssemblyVersion>4.1.1.0</AssemblyVersion>
<AssemblyVersion>4.1.2.0</AssemblyVersion>
<AssemblyVersion>5.0.0.0</AssemblyVersion>