Click here to Skip to main content
15,905,508 members
Home / Discussions / C#
   

C#

 
AnswerRe: Advancing On Pressing Enter Pin
Dan Mos8-Jun-10 20:47
Dan Mos8-Jun-10 20:47 
GeneralRe: Advancing On Pressing Enter Pin
Roger Wright8-Jun-10 20:52
professionalRoger Wright8-Jun-10 20:52 
GeneralRe: Advancing On Pressing Enter Pin
Dan Mos8-Jun-10 20:55
Dan Mos8-Jun-10 20:55 
AnswerRe: Advancing On Pressing Enter Pin
Henry Minute9-Jun-10 0:19
Henry Minute9-Jun-10 0:19 
AnswerRe: Advancing On Pressing Enter Pin
Richard Andrew x649-Jun-10 4:39
professionalRichard Andrew x649-Jun-10 4:39 
Questionbinning at zero-filling data Pin
shekarchee8-Jun-10 19:41
shekarchee8-Jun-10 19:41 
AnswerRe: binning at zero-filling data Pin
EliottA9-Jun-10 2:19
EliottA9-Jun-10 2:19 
AnswerRe: binning at zero-filling data Pin
LookSharp9-Jun-10 3:40
LookSharp9-Jun-10 3:40 
For text data, look for lines that don't contain an embedded space, then append " 0":

public List<string> CleanupText(List<string> inputLines)
    {
    List<string> outputLines = new List<string>();
    foreach (string s in inputLines)
        {
        // Note: the Trim() and Replace() ensure that (a) there are no false hits and (b) no false misses, respectively
        if (s.Trim().Replace('\t', ' ').Contains(" "))
            outputLines.Add(s);
        else
            outputLines.Add(string.Concat(s, " 0"));
        }
    return outputLines;
    }


If you want to modify the collection in place, you'll have to replace the foreach() with a for() and an index into the list - since foreach() loops disallow modifying the collection they are iterating.

To do this with Excel you'll have to iterate rows (the end condition being a cell in the first column that is empty), looking for cells in the 2nd column that are blank and inserting a '0' into those blank cells. I've not done enough MSOffice interop to be able to give you a code example.
QuestionClone Windows Forms Information Pin
Illegal Operation8-Jun-10 19:30
Illegal Operation8-Jun-10 19:30 
AnswerRe: Clone Windows Forms Information Pin
Anshul R8-Jun-10 20:27
Anshul R8-Jun-10 20:27 
AnswerRe: Clone Windows Forms Information Pin
Peace ON8-Jun-10 20:44
Peace ON8-Jun-10 20:44 
QuestionWindows application create an Excel file Pin
Member 44642398-Jun-10 11:45
Member 44642398-Jun-10 11:45 
AnswerRe: Windows application create an Excel file Pin
Dan Mos8-Jun-10 11:59
Dan Mos8-Jun-10 11:59 
AnswerRe: Windows application create an Excel file Pin
Ramkithepower9-Jun-10 4:01
Ramkithepower9-Jun-10 4:01 
Questionwindows application Pin
jashimu8-Jun-10 8:36
jashimu8-Jun-10 8:36 
AnswerRe: windows application Pin
Manas Bhardwaj8-Jun-10 9:08
professionalManas Bhardwaj8-Jun-10 9:08 
AnswerRe: windows application [modified] Pin
#realJSOP8-Jun-10 10:04
professional#realJSOP8-Jun-10 10:04 
AnswerRe: windows application Pin
LookSharp9-Jun-10 3:54
LookSharp9-Jun-10 3:54 
GeneralRe: windows application Pin
jashimu9-Jun-10 7:56
jashimu9-Jun-10 7:56 
QuestionLINQ DataContext and IDisposable Pin
Member 39190498-Jun-10 7:01
Member 39190498-Jun-10 7:01 
AnswerRe: LINQ DataContext and IDisposable Pin
Pete O'Hanlon8-Jun-10 10:01
mvePete O'Hanlon8-Jun-10 10:01 
QuestionIndexer Question Pin
David Knechtges8-Jun-10 5:54
David Knechtges8-Jun-10 5:54 
AnswerRe: Indexer Question Pin
harold aptroot8-Jun-10 6:10
harold aptroot8-Jun-10 6:10 
AnswerRe: Indexer Question Pin
T M Gray8-Jun-10 10:45
T M Gray8-Jun-10 10:45 
GeneralRe: Indexer Question Pin
harold aptroot8-Jun-10 10:56
harold aptroot8-Jun-10 10:56 

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.