c# - How can I reduce the variables used in this code? -


i trying reduce amount of variables used in code below.
ideally keep reusing string variable latestripme without creating latestripmeversion string[] variable.
need create array in order skip(1) , first()?
can reach final value of latestripme more efficiently?

private void ripmegetlatestversion_process() {     //get .json file , save in latestripme string     latestripme = clientripme.downloadstring("http://www.rarchives.com/ripme.json");      //create array saved string, , skip first line     latestripmeversion = latestripme.split(environment.newline.tochararray()).skip(1).toarray();      //put array in string, , select first line     latestripme = latestripmeversion.first();      //the characters need removed     char[] latestripmetrim = { ' ', ' ', '"', 'l', 'a', 't', 'e', 's', 't', 'v', 'e', 'r', 's', 'i', 'o', 'n', '"', ' ', ':', ' ', '"', '"', ',' };      //trim above declared characters     latestripme = latestripme.trim(latestripmetrim);      //show remaining string content in textblock     latestripmeversiontext.text = "latest ripme version: " + latestripme; } 

you can replace

  //create array saved string, , skip first line   latestripmeversion = latestripme.split(environment.newline.tochararray()).skip(1).toarray();    //put array in string, , select first line   latestripme = latestripmeversion.first(); 

with

  latestripme = latestripme.split(environment.newline.tochararray())[1]; 

or

  latestripme = latestripme            .split(environment.newline.tochararray())[1]            .trim(new char[] { ' ', 'a', 'b' });  // etc ... 

opinion:
style wise, ugly, difficult debug , and throw exception site doesn't return expect (no internet connection, etc). don't understand desire replace clear, documented step step code reduce number of variables unless programming challenge.


Comments

Popular posts from this blog

mongodb - How to keep track of users making Stripe Payments -

javascript - Fire on return from form "Submit" -

javascript - Thinglink image not visible until browser resize -