11using System ;
22using System . Collections . Generic ;
3- using System . IO ;
4- using System . Linq ;
53using System . Text . RegularExpressions ;
64
75namespace Open . Text . CSV
@@ -18,12 +16,12 @@ public static string[] GetLine(string line, ref int maxColumns)
1816 return StringArrayEmpty ;
1917
2018 var mc = LinePattern . Matches ( line ) ;
21- int c = mc . Count ;
19+ var c = mc . Count ;
2220 if ( c > maxColumns )
2321 maxColumns = c ;
2422
2523 var result = new string [ c ] ;
26- for ( int i = 0 ; i < c ; i ++ )
24+ for ( var i = 0 ; i < c ; i ++ )
2725 result [ i ] = mc [ i ] . Groups [ 1 ] . Value . Trim ( '"' ) ;
2826
2927 return result ;
@@ -32,18 +30,18 @@ public static string[] GetLine(string line, ref int maxColumns)
3230 public static string [ ] [ ] GetArray ( string csv , out int maxColumns )
3331 {
3432 maxColumns = 0 ;
35- string [ ] lines = csv == null ? new string [ 0 ] : csv . Split ( '\n ' ) ;
33+ var lines = csv == null ? new string [ 0 ] : csv . Split ( '\n ' ) ;
3634
3735 var result = new List < string [ ] > ( lines . Length ) ;
38- foreach ( string line in lines )
36+ foreach ( var line in lines )
3937 result . Add ( GetLine ( line , ref maxColumns ) ) ;
4038
4139 return result . ToArray ( ) ;
4240 }
4341
4442 public static string [ ] [ ] GetArray ( string csv )
4543 {
46- return GetArray ( csv , out int maxColumns ) ;
44+ return GetArray ( csv , out var maxColumns ) ;
4745 }
4846
4947
@@ -53,25 +51,25 @@ public static string[][] GetArray(string csv)
5351 public static string WrapQuotes ( string value )
5452 {
5553 if ( value == null )
56- return String . Empty ;
54+ return string . Empty ;
5755
5856 return '"' + value . Replace ( "\" " , "\" \" " ) + '"' ;
5957 }
6058
6159 public static string FormatValue ( string value , bool forceQuotes = false )
6260 {
6361 if ( value == null )
64- return String . Empty ;
62+ return string . Empty ;
6563
66- if ( ! String . IsNullOrEmpty ( value ) && forceQuotes || QUOTESNEEDED . IsMatch ( value ) )
64+ if ( ! string . IsNullOrEmpty ( value ) && forceQuotes || QUOTESNEEDED . IsMatch ( value ) )
6765 return WrapQuotes ( value ) ;
6866
6967 return value ;
7068 }
7169
7270 public static string ExportValue ( object value , bool forceQuotes = false )
7371 {
74- string result = String . Empty ;
72+ var result = string . Empty ;
7573 if ( value != null ) // && value != DBNull.Value)
7674 {
7775 if ( value is DateTime datetime )
0 commit comments