Click here to Skip to main content
15,917,005 members
Home / Discussions / C#
   

C#

 
GeneralRe: Where are the libraries located in C#? Pin
Luc Pattyn4-Apr-19 1:07
sitebuilderLuc Pattyn4-Apr-19 1:07 
GeneralRe: Where are the libraries located in C#? Pin
Brian_TheLion4-Apr-19 10:03
Brian_TheLion4-Apr-19 10:03 
GeneralRe: Where are the libraries located in C#? Pin
Luc Pattyn4-Apr-19 11:52
sitebuilderLuc Pattyn4-Apr-19 11:52 
QuestionDetect Samsung Tablet Plugged Into USB Pin
Kevin Marois3-Apr-19 14:34
professionalKevin Marois3-Apr-19 14:34 
AnswerRe: Detect Samsung Tablet Plugged Into USB Pin
Eddy Vluggen3-Apr-19 21:44
professionalEddy Vluggen3-Apr-19 21:44 
AnswerRe: Detect Samsung Tablet Plugged Into USB Pin
OriginalGriff4-Apr-19 5:01
mveOriginalGriff4-Apr-19 5:01 
AnswerRe: Detect Samsung Tablet Plugged Into USB Pin
Gerry Schmitz4-Apr-19 5:21
mveGerry Schmitz4-Apr-19 5:21 
QuestionHow exactly is locking performed with IIS and a web.config? Pin
Xarzu2-Apr-19 16:46
Xarzu2-Apr-19 16:46 
AnswerRe: How exactly is locking performed with IIS and a web.config? Pin
Richard Deeming3-Apr-19 0:11
mveRichard Deeming3-Apr-19 0:11 
QuestionWhat are the settings I need to have in order to run debug in Visual Studio for a program set up in the IIS? Pin
Xarzu2-Apr-19 9:51
Xarzu2-Apr-19 9:51 
AnswerRe: What are the settings I need to have in order to run debug in Visual Studio for a program set up in the IIS? Pin
Ron Nicholson2-Apr-19 11:02
professionalRon Nicholson2-Apr-19 11:02 
QuestionRDLC Report with nested row groups Pin
Member 140571372-Apr-19 8:28
Member 140571372-Apr-19 8:28 
QuestionUpdate User Environment Variable Pin
DavPCode2-Apr-19 4:50
DavPCode2-Apr-19 4:50 
AnswerRe: Update User Environment Variable Pin
OriginalGriff2-Apr-19 5:50
mveOriginalGriff2-Apr-19 5:50 
GeneralRe: Update User Environment Variable Pin
DavPCode2-Apr-19 7:12
DavPCode2-Apr-19 7:12 
GeneralRe: Update User Environment Variable Pin
Richard Deeming2-Apr-19 8:06
mveRichard Deeming2-Apr-19 8:06 
GeneralRe: Update User Environment Variable Pin
DavPCode2-Apr-19 12:07
DavPCode2-Apr-19 12:07 
QuestionValues Sum in a file Pin
Member 1420343029-Mar-19 10:46
Member 1420343029-Mar-19 10:46 
AnswerRe: Values Sum in a file Pin
OriginalGriff29-Mar-19 21:21
mveOriginalGriff29-Mar-19 21:21 
AnswerRe: Values Sum in a file Pin
Member 1420343030-Mar-19 3:29
Member 1420343030-Mar-19 3:29 
AnswerRe: Values Sum in a file Pin
BillWoodruff31-Mar-19 19:25
professionalBillWoodruff31-Mar-19 19:25 
It's good you got your code working !

I am going to respond with an example of using Linq that, imho, is valuable/educational because it illustrates using an index in a 'Select statement, dealing with the fact there is no equivalent to 'continue, or 'break, in a 'Select statement, and using 'GroupBy and 'ToDictionary to perform summation of the 'Value part of an 'IGroup:
C#
string s = @"d1.8xlarge: 3 d1.xlarge: 0 c2.xlarge: 25
s1.medium: 1 c2.xlarge: 10 s1.large: 4 d1.8xlarge: 27";

string[] split = s.Split(new char[] {' ',':', '\r','\n'}, StringSplitOptions.RemoveEmptyEntries);

int limit = split.Length - 1;

var sorted = split.Select((string str, int ndx) => // declaration of auto-index
{
    int val;  // use of variable defined inside 'Select

    if (ndx < limit && int.TryParse(split[ndx + 1], out val))
    {
        return new {name = split[ndx], value = val};
    }
    else
    {
        return null; // you have to return something !
    }
})
.Where(itm => itm != null) // get rid of 'nulls
.GroupBy(itm => itm.name) // group on the 'name
.ToDictionary(grp => grp.Key, grp => grp.Sum(v => v.value)); // summation
I'm not claiming this is the best solution ! But, imho, the aspects of using Linq it demonstrates are very useful in many other situations.
«Where is the Life we have lost in living? Where is the wisdom we have lost in knowledge? Where is the knowledge we have lost in information?» T. S. Elliot

QuestionSplit lines in a file Pin
Member 1420343029-Mar-19 8:34
Member 1420343029-Mar-19 8:34 
AnswerRe: Split lines in a file Pin
OriginalGriff29-Mar-19 9:11
mveOriginalGriff29-Mar-19 9:11 
QuestionException while trying reading a local file using online compiler Pin
Member 1420343029-Mar-19 6:28
Member 1420343029-Mar-19 6:28 
AnswerRe: Exception while trying reading a local file using online compiler Pin
OriginalGriff29-Mar-19 6:42
mveOriginalGriff29-Mar-19 6:42 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.