Explain piece of C# code and conversion to VB.NET -
yesterday asked question. rubens farias answered pointing piece of code wrote. following part of cannot compiled ms visual studio 2010 professional beta 2.
byte[] buffer = encoding.utf8.getbytes( string.join("&", array.convertall<keyvaluepair<string, string>, string>( inputs.toarray(), delegate(keyvaluepair item) { return item.key + "=" + httputility.urlencode(item.value); }))); it gives these errors in visual studio. unfortunately rubens doesn't reply anymore.
so have following questions / requests:
- i don't understand piece of code, please explain happening exactly.
- please explain how part has te rewritten in order "work" in vs.
- please explain how should convert vb.net. have tried using online converters no avail.
- keyvaluepair requires 2 type arguments. in delegate declaration says
keyvaluepair item, no type arguments. changedelegate(keyvaluepair<string,string> item) httputilitydeclared insystem.webnamespace; addusing system.web;using statements in beginning of file.
personally find easier , cleaner use lambda style kind of code:
byte[] buffer = encoding.utf8.getbytes( string.join("&", array.convertall<keyvaluepair<string, string>, string>( inputs.toarray(), (item) => item.key + "=" + httputility.urlencode(item.value)))); once have gotten c# code work, developerfusion c# vb.net converter job:
' converted delegate style c# implementation ' dim buffer byte() = encoding.utf8.getbytes( _ [string].join("&", _ array.convertall(of keyvaluepair(of string, string), string)(inputs.toarray(), _ function(item keyvaluepair(of string, string)) (item.key & "=") + httputility.urlencode(item.value)))) ' converted lambda style c# implementation ' dim buffer byte() = encoding.utf8.getbytes( _ [string].join("&", _ array.convertall(of keyvaluepair(of string, string), string)(inputs.toarray(), _ function(item) (item.key & "=") + httputility.urlencode(item.value))))
Comments
Post a Comment