Search Results

Search found 301 results on 13 pages for 'edward tanguay'.

Page 9/13 | < Previous Page | 5 6 7 8 9 10 11 12 13  | Next Page >

  • How to automatically read in calculated values with PHPExcel?

    - by Edward Tanguay
    I have the following Excel file: I read it in by looping over every cell and getting the value with getCell(...)->getValue(): $highestColumnAsLetters = $this->objPHPExcel->setActiveSheetIndex(0)->getHighestColumn(); //e.g. 'AK' $highestRowNumber = $this->objPHPExcel->setActiveSheetIndex(0)->getHighestRow(); $highestColumnAsLetters++; for ($row = 1; $row < $highestRowNumber + 1; $row++) { $dataset = array(); for ($columnAsLetters = 'A'; $columnAsLetters != $highestColumnAsLetters; $columnAsLetters++) { $dataset[] = $this->objPHPExcel->setActiveSheetIndex(0)->getCell($columnAsLetters.$row)->getValue(); if ($row == 1) { $this->column_names[] = $columnAsLetters; } } $this->datasets[] = $dataset; } However, although it reads in the data fine, it reads in the calculations literally: I understand from discussions like this one that I can use getCalculatedValue() for calculated cells. The problem is that in the Excel sheets I am importing, I do not know beforehand which cells are calculated and which are not. Is there a way for me to read in the value of a cell in a way that automatically gets the value if it has a simple value and gets the result of the calculation if it is a calculation?

    Read the article

  • How can I get jquery to toggle-fade a flashcard div open and closed on click?

    - by Edward Tanguay
    What do I have to change to the code below in order for the user to click on a flashcard header to open and close the flashcard answer? I couldn't get toggle() to work with fadein/fadeout the version below doesn't respond to the click code: <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <script type="text/javascript" src="http://www.google.com/jsapi"></script> <script type="text/javascript"> google.load("jquery", "1.4.1"); google.setOnLoadCallback(function() { $("div > div.question").click(function() { if($(this).next().is(":hidden") { $(this).next().fadeIn("slow"); } else { $(this).next().fadeOut("slow"); } }); }); </script> <style> div.flashcard { margin: 0 10px 10px 0; } div.flashcard div.question { background-color:#ddd; width: 400px; padding: 5px; cursor: hand; cursor: pointer; } div.flashcard div.answer { background-color:#eee; width: 400px; padding: 5px; display: none; } </style> </head> <body> <div id="1" class="flashcard"> <div class="question">Who was Wagner?</div> <div class="answer">German composer, conductor, theatre director and essayist, primarily known for his operas (or "music dramas", as they were later called). Unlike most other opera composers, Wagner wrote both the music and libretto for every one of his works.</div> </div> <div id="2" class="flashcard"> <div class="question">Who was Thalberg?</div> <div class="answer">a composer and one of the most distinguished virtuoso pianists of the 19th century.</div> </div> </body> </html>

    Read the article

  • What do I have to change in my PHP/CURL code to retrieve data from a https:// URL?

    - by Edward Tanguay
    I have a PHP file using CURL that accepts a Google Doc URL as a parameter, then returns the plain text of the Google Doc. It worked well until recently when apparently a redirect was added so that the http:// address redirects to the equivalent https:// address, as in this example: http://docs.google.com/View?id=dc7gj86r_20dn2csqg3 So I changed my code to access the https:// address, but it just returns blank. What do I have to change my CURL code so that I can get the HTML text from the https:// address? $url = filter_input(INPUT_GET, 'url',FILTER_SANITIZE_STRING); $validUrlPrefixes[] = "https://docs.google.com"; if(beginsWithOneOfThese($url, $validUrlPrefixes)) { $user_agent = 'Mozilla/5.0 (Windows; U; Windows NT 6.1; en-US; rv:1.9.2.3) Gecko/20100401 Firefox/3.6.3 (.NET CLR 3.5.30729)'; $ch = curl_init(); curl_setopt($ch, CURLOPT_COOKIEJAR, "/tmp/cookie"); curl_setopt($ch, CURLOPT_COOKIEFILE, "/tmp/cookie"); curl_setopt($ch, CURLOPT_URL, $url ); curl_setopt($ch, CURLOPT_FAILONERROR, 1); curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 0); curl_setopt($ch, CURLOPT_RETURNTRANSFER,1); curl_setopt($ch, CURLOPT_TIMEOUT, 15); curl_setopt($ch, CURLOPT_USERAGENT, $user_agent); curl_setopt($ch, CURLOPT_VERBOSE, 0); $rawData = curl_exec($ch); $rawData = cleanText($rawData); if(beginsWith($url, "https://docs.google.com")) { echo qstr::convertGoogleDocContentToText($rawData); die; } echo $rawData; die;

    Read the article

  • How to get the coordinates of an image mouse click in the event handler?

    - by Edward Tanguay
    In the following WPF app, I have an Image in a ContentControl. When the user clicks on the image, how can I get the x/y coordinates of where the mouse clicked on the image? XAML: <Window x:Class="TestClick828374.Window1" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" Title="Window1" Height="300" Width="300"> <StackPanel Margin="10"> <ContentControl Content="{Binding TheImage}" MouseDown="ContentControl_MouseDown"/> </StackPanel> </Window> Code-Behind: using System; using System.Windows; using System.Windows.Controls; using System.Windows.Media; using System.Windows.Media.Imaging; using System.ComponentModel; namespace TestClick828374 { public partial class Window1 : Window, INotifyPropertyChanged { #region ViewModelProperty: TheImage private Image _theImage; public Image TheImage { get { return _theImage; } set { _theImage = value; OnPropertyChanged("TheImage"); } } #endregion public Window1() { InitializeComponent(); DataContext = this; TheImage = new Image(); TheImage.Source = new BitmapImage(new Uri(@"c:\test\rectangle.png")); TheImage.Stretch = Stretch.None; TheImage.HorizontalAlignment = HorizontalAlignment.Left; } #region INotifiedProperty Block public event PropertyChangedEventHandler PropertyChanged; protected void OnPropertyChanged(string propertyName) { PropertyChangedEventHandler handler = PropertyChanged; if (handler != null) { handler(this, new PropertyChangedEventArgs(propertyName)); } } #endregion private void ContentControl_MouseDown(object sender, System.Windows.Input.MouseButtonEventArgs e) { //how to get the coordinates of the mouse click here on the image? } } }

    Read the article

  • What is the fastest way to trim blank lines from beginning and end of array?

    - by Edward Tanguay
    This script: <?php $lines[] = ''; $lines[] = 'first line '; $lines[] = 'second line '; $lines[] = ''; $lines[] = 'fourth line'; $lines[] = ''; $lines[] = ''; $lineCount = 1; foreach($lines as $line) { echo $lineCount . ': [' . trim($line) . ']<br/>'; $lineCount++; } ?> produces this output: 1: [] 2: [first line] 3: [second line] 4: [] 5: [fourth line] 6: [] 7: [] What is the fastest, most efficient way to change the above script so that it also deletes the preceding and trailing blank entries but not the interior blank entries so that it outputs this: 1: [first line] 2: [second line] 3: [] 4: [fourth line] I could use the foreach loop but I imagine there is a way with array_filter or something similar which is much more efficient.

    Read the article

  • How to handle not-enough-isolatedstorage issue deep in data loader?

    - by Edward Tanguay
    I have a silverlight application which loads data from many external data sources into IsolatedStorage, and while loading any of these sources if it does not have enough IsolatedStorage, it ends up in a catch statement. At that point in that catch statement I would like to ask the user to click a button to approve silverlight to increase the IsolatedStorage capacity. The problem is, although I have a "SwitchPage()" method with which I display a page, if I access it at this point it is too deep in the loading process and the application always goes into an endless loop, hangs and crashes. I need a way to branch out of the application completely somehow to an independent UserControl which has a button and code behind which does the increase logic. What is a solution for an application to be able to branch out of a loading process catch statement like this, display a user control which has a button to ask the user to increase the IsolatedStorage? public static void SaveBitmapImageToIsolatedStorageFile(OpenReadCompletedEventArgs e, string fileName) { try { using (IsolatedStorageFile isf = IsolatedStorageFile.GetUserStoreForApplication()) { using (IsolatedStorageFileStream isfs = new IsolatedStorageFileStream(fileName, FileMode.Create, isf)) { Int64 imgLen = (Int64)e.Result.Length; byte[] b = new byte[imgLen]; e.Result.Read(b, 0, b.Length); isfs.Write(b, 0, b.Length); isfs.Flush(); isfs.Close(); isf.Dispose(); } } } catch (IsolatedStorageException) { //handle: present user with button to increase isolated storage } catch (TargetInvocationException) { //handle: not saved } }

    Read the article

  • How to refer to items in Dictionary<string, string> by integer index?

    - by Edward Tanguay
    I made a Dictionary<string, string> collection so that I can quickly reference the items by their string identifier. But I now also need to access this collective by index counter (foreach won't work in my real example). What do I have to do to the collection below so that I can access its items via integer index as well? using System; using System.Collections.Generic; using System.Linq; using System.Text; namespace TestDict92929 { class Program { static void Main(string[] args) { Dictionary<string, string> events = new Dictionary<string, string>(); events.Add("first", "this is the first one"); events.Add("second", "this is the second one"); events.Add("third", "this is the third one"); string description = events["second"]; Console.WriteLine(description); string description = events[1]; //error Console.WriteLine(description); } } }

    Read the article

  • Why is a Silverlight application created from an exported template show a blank screen in the browse

    - by Edward Tanguay
    I created a silverlight app (without website) named TestApp, with one TextBox: <UserControl x:Class="TestApp.MainPage" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:d="http://schemas.microsoft.com/expression/blend/2008" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" mc:Ignorable="d" d:DesignWidth="640" d:DesignHeight="480"> <Grid x:Name="LayoutRoot"> <TextBlock Text="this is a test"/> </Grid> </UserControl> I press F5 and see "this is a test" in my browser (firefox). I select File | Export Template | name it TestAppTemplate and save it. I create a new silverlight app based on the above template. The MainPage.xaml has the exact same XAML as above. I press F5 and see a blank screen in my browser. I look at the HTML source of both of these and they are identical. Everything I have compared in both projects is identical. What do I have to do so that a Silverlight application which is created from my exported template does not show a blank screen?

    Read the article

  • Strategies for when to use properties and when to use internal variables on internal classes?

    - by Edward Tanguay
    In almost all of my classes, I have a mixture of properties and internal class variables. I have always chosen one or the other by the rule "property if you need it externally, class variable if not". But there are many other issues which make me rethink this often, e.g.: at some point I want to use an internal variable from outside the class, so I have to refactor it into a property which makes me wonder why I don't just make all my internal variables properties in case I have to access them externally anyway, since most classes are internal classes anyway it aren't exposed on an API so it doesn't really matter if the internal variables are accessible from outside the class or not but then since C# doesn't allow you to instantiate e.g. List<string> property in the definition, then these properties have to be initialized in every possible constructor, so these variables I would rather have internal variables just to keep things cleaner in that they are all initialized in one place C# code reads more cleanly if constructor/method parameters are camel case and you assign them to pascal case properties instead of the ambiguity of seeing "templateIdCode" and having to look around to see if it is a local variable, method parameter or internal class variable, e.g. it is easier when you see "TemplateIdCode = templateIdCode" that this is a parameter being assigned to a class property. This would be an argument for always using only properties on internal classes. e.g.: public class TextFile { private string templateIdCode; private string absoluteTemplatePathAndFileName; private string absoluteOutputDirectory; private List<string> listItems = new List<string>(); public string Content { get; set; } public List<string> ReportItems { get; set; } public TextFile(string templateIdCode) { this.templateIdCode = templateIdCode; ReportItems = new List<string>(); Initialize(); } ... When creating internal (non-API) classes, what are your strategies in deciding if you should create an internal class variable or a property?

    Read the article

  • What is the best way in Silerlight to make areas of a large graphic clickable?

    - by Edward Tanguay
    In a Silverlight application I have large images which have flow charts on them. I need to handle the clicks on specific hotspots of the image where the flow chart boxes are. Since the flow charts will always be different, the information of where the hotspots has to be dynamic, e.g. in a list of coordinates. I've found article like this one but don't need the detail of e.g. the outline of countries but just simple rectangle and circle areas. I've also found articles where they talk about overlaying an HTML image map over the silverlight application, but it has to be easier than this. What is the best way to handle clicks on specific areas of an image in silverlight?

    Read the article

  • Why would Visual Studio 2010 say it can't show a variable during debug?

    - by Edward Tanguay
    In Visual Studio 2010 sometimes when I want to get the value of a variable while debugging, it tells me that it "does not exist in this context" when it obviously does. I have found that if I use the variable, as in the screenshot below, then it is able to show it. Has anyone experienced this? Visual Studio 2008 never did this. How can I get Visual Studio 2010 to always show me variable values while debugging?

    Read the article

  • How to get Firefox to not continue to show "Transferring data from..." in browser status bar after a

    - by Edward Tanguay
    The following silverlight demo loads and displays a text file from a server. However, in Firefox (but not Explorer or Chrome) after you click the button and the text displays, the status bar continues to show "Transferring data from test.development..." which erroneously gives the user the belief that something is still loading. I've noticed that if you click on another Firefox tab and then back on the original one, the message goes away, so it seems to be just a Firefox bug that doesn't clear the status bar automatically. Is there a way to clear the status bar automatically in Firefox? or a way to explicitly tell it that the async loading is finished so it can clear the status bar itself? XAML: <UserControl x:Class="TestLoad1111.MainPage" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"> <StackPanel Margin="10"> <StackPanel HorizontalAlignment="Left" Orientation="Horizontal" Margin="0 0 0 10"> <Button Content="Load Text" Click="Button_LoadText_Click"/> </StackPanel> <TextBlock Text="{Binding Message}" /> </StackPanel> </UserControl> Code Behind: using System; using System.Net; using System.Windows; using System.Windows.Controls; using System.ComponentModel; namespace TestLoad1111 { public partial class MainPage : UserControl, INotifyPropertyChanged { #region ViewModelProperty: Message private string _message; public string Message { get { return _message; } set { _message = value; OnPropertyChanged("Message"); } } #endregion public MainPage() { InitializeComponent(); DataContext = this; } private void Button_LoadText_Click(object sender, RoutedEventArgs e) { WebClient webClientTextLoader = new WebClient(); webClientTextLoader.DownloadStringAsync(new Uri("http://test.development:111/testdata/test.txt?" + Helpers.GetRandomizedSuffixToPreventCaching())); webClientTextLoader.DownloadStringCompleted += new DownloadStringCompletedEventHandler(webClientTextLoader_DownloadStringCompleted); } void webClientTextLoader_DownloadStringCompleted(object sender, DownloadStringCompletedEventArgs e) { Message = e.Result; } #region INotifiedProperty Block public event PropertyChangedEventHandler PropertyChanged; protected void OnPropertyChanged(string propertyName) { PropertyChangedEventHandler handler = PropertyChanged; if (handler != null) { handler(this, new PropertyChangedEventArgs(propertyName)); } } #endregion } public static class Helpers { private static Random random = new Random(); public static int GetRandomizedSuffixToPreventCaching() { return random.Next(10000, 99999); } } }

    Read the article

  • Why do firefox/chrome show a different page than IE8?

    - by Edward Tanguay
    When I look at this published Google Docs document, I see the latest version with Firefox and Chrome, but an older version with IE8. Also, screen-scraping it via PHP/Curl gives me an older version. I've tried CTRL-Refresh in IE8 but I can't get it to show me the newest version. No matter what headers I try to change in PHP/Curl, I can't get it to show me the newest version. What am I not understanding about browsers/headers/caching here? How can it be that different browsers show different contents of one page?

    Read the article

  • In MVVM are DataTemplates considered Views as UserControls are Views?

    - by Edward Tanguay
    In MVVM, every View has a ViewModel. A View I understand to be a Window, Page or UserControl to which you can attach a ViewModel from which the view gets its data. But a DataTemplate can also render a ViewModel's data. So I understand a DataTemplate to be another "View", but there seem to be differences, e.g. Windows, Pages, and UserControls can define their own .dlls, one type is bound with DataContect the other through attaching a template so that Windows, Pages, UserControls can can be attached to ViewModels dynamically by a ServiceLocator/Container, etc. How else are DataTemplates different than Windows/Pages/UserControls when it comes to rendering a ViewModel's data on the UI? And are there other types of "Views" other than these four?

    Read the article

  • Why don't I have access to setReadDataOnly() or enableMemoryOptimization() in PHPExcel?

    - by Edward Tanguay
    I've downloaded PHPExcel 1.7.5 Production. I would like to use setReadDataOnly() and enableMemoryOptimization() as discussed in their forum here and in stackoverflow questions. However when I use them, I get a Call to undefined method error. Is there another version or some plugin or library that I have not installed? What do I have to do to access these methods? $objPHPExcel = PHPExcel_IOFactory::load("data/".$file_name); $objPHPExcel->setReadDataOnly(true); //Call to undefined method $objPHPExcel->enableMemoryOptimization(); //Call to undefined method

    Read the article

  • Why would my Silverlight 4 Out-of-Browser application just display white?

    - by Edward Tanguay
    My Silverlight application works fine when running in a browser. But when I install it as an out-of-browser application, the Window frame comes up with an appropriate icon and title, but the content of the window is just white. It is in the start menu but when I close it and open again, it is still blank. I reproduced this on Windows 7 and Windows XP. What could be causing my silverlight application to show only white when running out-of-browser? Here are the settings I used:

    Read the article

  • Why does this textbox binding example work in WPF but not in Silverlight?

    - by Edward Tanguay
    Why is it in the following silverlight application that when I: change the default text in the first textbox move the cursor to the second text box (i.e. take focus off first textbox) click the button that inside the button handler, it still has the old value "default text"? What do I have to do to get the binding to work in Silverlight? The same code works fine in WPF. XAML: <UserControl x:Class="TestUpdate123.MainPage" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:d="http://schemas.microsoft.com/expression/blend/2008" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" mc:Ignorable="d" d:DesignWidth="640" d:DesignHeight="480"> <StackPanel Margin="10" HorizontalAlignment="Left"> <TextBox Text="{Binding InputText}" Height="200" Width="600" Margin="0 0 0 10"/> <StackPanel HorizontalAlignment="Left"> <Button Content="Convert" Click="Button_Convert_Click" Margin="0 0 0 10"/> </StackPanel> <TextBox Height="200" Width="600" Margin="0 0 0 10"/> <TextBlock Text="{Binding OutputText}"/> </StackPanel> </UserControl> Code Behind: using System.Windows; using System.Windows.Controls; using System.ComponentModel; namespace TestUpdate123 { public partial class MainPage : UserControl, INotifyPropertyChanged { #region ViewModelProperty: InputText private string _inputText; public string InputText { get { return _inputText; } set { _inputText = value; OnPropertyChanged("InputText"); } } #endregion #region ViewModelProperty: OutputText private string _outputText; public string OutputText { get { return _outputText; } set { _outputText = value; OnPropertyChanged("OutputText"); } } #endregion public MainPage() { InitializeComponent(); DataContext = this; InputText = "default text"; } private void Button_Convert_Click(object sender, RoutedEventArgs e) { OutputText = InputText; } #region INotifiedProperty Block public event PropertyChangedEventHandler PropertyChanged; protected void OnPropertyChanged(string propertyName) { PropertyChangedEventHandler handler = PropertyChanged; if (handler != null) { handler(this, new PropertyChangedEventArgs(propertyName)); } } #endregion } }

    Read the article

  • How to get the height of an Image in Silverlight?

    - by Edward Tanguay
    I have this code in Silverlight: Image image = new Image(); BitmapImage bitmapImage= TheDatasourceManager.GetBitmapImage("blackPencil"); image.Source = bitmapImage; image.Stretch = Stretch.None; image.HorizontalAlignment = HorizontalAlignment.Left; image.VerticalAlignment = VerticalAlignment.Top; image.Margin = new Thickness(88, 88, 0, 0); grid.Children.Add(image); Now I want to find out the height of the image. in WPF I can get it with image.Source.Height but this is not available in Silverlight bitmapImage.Height doesn't exist either when I debug and examine the image object, I eventually get to PixelHeight which has an accurate height, but I can't seem to access it I find image.ActualHeight but it is 0. How can I get the height of the image?

    Read the article

  • In Vim, what is the best way to select, delete, or comment out large portions of multi-screen text?

    - by Edward Tanguay
    Selecting a large amount of text that extends over many screens in an IDE like Eclipse is fairly easy since you can use the mouse, but what is the best way to e.g. select and delete multiscreen blocks of text or write e.g. three large methods out to another file and then delete them for testing purposes in Vim when using it via putty/ssh where you cannot use the mouse? I can easily yank-to-the-end-of-line or yank-to-the-end-of-code-block but if the text extends over many screens, or has lots of blank lines in it, I feel like my hands are tied in Vim. Any solutions? And a related question: is there a way to somehow select 40 lines, and then comment them all out (with "#" or "//"), as is common in most IDEs?

    Read the article

  • How to SELECT the last 10 rows of an SQL table which has no ID field?

    - by Edward Tanguay
    I have an MySQL table with 25000 rows. This is an imported CSV file so I want to look at the last ten rows to make sure it imported everything. However, since there is no ID column, I can't say: SELECT * FROM big_table ORDER BY id DESC What SQL statement would show me the last 10 rows of this table? The structure of the table is simply this: columns are: A, B, C, D, ..., AA, AB, AC, ... (like Excel) all fields are of type TEXT

    Read the article

  • What is the best way to return two values from a method?

    - by Edward Tanguay
    When I have to write methods which return two values, I usually go about it as in the following code which returns a List<string>. Or if I have to return e.g. a id and string, then I return a List<object> and then pick them out with index number and recast the values. This recasting and referencing by index seems inelegant so I want to develop a new habit for methods that return two values. What is the best pattern for this? using System; using System.Collections.Generic; using System.Linq; namespace MultipleReturns { class Program { static void Main(string[] args) { string extension = "txt"; { List<string> entries = GetIdCodeAndFileName("first.txt", extension); Console.WriteLine("{0}, {1}", entries[0], entries[1]); } { List<string> entries = GetIdCodeAndFileName("first", extension); Console.WriteLine("{0}, {1}", entries[0], entries[1]); } Console.ReadLine(); } /// <summary> /// gets "first.txt", "txt" and returns "first", "first.txt" /// gets "first", "txt" and returns "first", "first.txt" /// it is assumed that extensions will always match /// </summary> /// <param name="line"></param> public static List<string> GetIdCodeAndFileName(string line, string extension) { if (line.Contains(".")) { List<string> parts = line.BreakIntoParts("."); List<string> returnItems = new List<string>(); returnItems.Add(parts[0]); returnItems.Add(line); return returnItems; } else { List<string> returnItems = new List<string>(); returnItems.Add(line); returnItems.Add(line + "." + extension); return returnItems; } } } public static class StringHelpers { public static List<string> BreakIntoParts(this string line, string separator) { if (String.IsNullOrEmpty(line)) return null; else { return line.Split(new string[] { separator }, StringSplitOptions.None).Select(p => p.Trim()).ToList(); } } } }

    Read the article

  • How can I unattach an element from another element in the XAML tree?

    - by Edward Tanguay
    In my Silverlight application, I load all the images I need at application start and store them in a dictionary. Then as I need them I pick them out of the dictionary and attach them in XAML trees etc. However, I have the problem that if I attach an Image object to a Grid, then want to use that image again, it tells me: The image element is already a child of another element. How can I run through my dictionary and "detach all images from parent XAML elements"?

    Read the article

  • Is there a more elegant way to act on the first and last items in a foreach enumeration than count++

    - by Edward Tanguay
    Is there a more elegant way to act on the first and last items when iterating through a foreach loop than incrementing a separate counter and checking it each time? For instance, the following code outputs: >>> [line1], [line2], [line3], [line4] <<< which requires knowing when you are acting on the first and last item. Is there a more elegant way to do this now in C# 3 / C# 4? It seems like I could use .Last() or .First() or something like that. using System; using System.Collections.Generic; using System.Text; namespace TestForNext29343 { class Program { static void Main(string[] args) { StringBuilder sb = new StringBuilder(); List<string> lines = new List<string> { "line1", "line2", "line3", "line4" }; int index = 0; foreach (var line in lines) { if (index == 0) sb.Append(">>> "); sb.Append("[" + line + "]"); if (index < lines.Count - 1) sb.Append(", "); else sb.Append(" <<<"); index++; } Console.WriteLine(sb.ToString()); Console.ReadLine(); } } }

    Read the article

< Previous Page | 5 6 7 8 9 10 11 12 13  | Next Page >