Search Results

Search found 6580 results on 264 pages for 'boost foreach'.

Page 126/264 | < Previous Page | 122 123 124 125 126 127 128 129 130 131 132 133  | Next Page >

  • Parsing Tabular cell data with space where there is td tag.

    - by Harikrishna
    I am parsing html tabular information with the help of the html agility pack. Now First I am finding the rows in that table like var rows = table.Descendants("tr"); then I find the cell data for each row like foreach(var row in rows) { string rowInnerText = row.InnerText; } That gives me the cell data.But with no spaces between them like NameAdressPhone No but I want the innertext like Name Address Phone No means where there is td tag I want to keep there one space between different column cell.

    Read the article

  • using Hibernate to loading 20K products, modifying the entity and updating to db

    - by Blankman
    I am using hibernate to update 20K products in my database. As of now I am pulling in the 20K products, looping through them and modifying some properties and then updating the database. so: load products foreach products session begintransaction productDao.MakePersistant(p); session commit(); As of now things are pretty slow compared to your standard jdbc, what can I do to speed things up? I am sure I am doing something wrong here.

    Read the article

  • Will First() perform the OrderBy()?

    - by Martin
    Is there any difference in (asymptotic) performance between Orders.OrderBy(order => order.Date).First() and Orders.Where(order => order.Date == Orders.Max(x => x.Date)); i.e. will First() perform the OrderBy()? I'm guessing no. MSDN says enumerating the collection via foreach och GetEnumerator does but the phrasing does not exclude other extensions.

    Read the article

  • Automatically unsubscribe an event

    - by Cat
    Is it possible to do something like this in C#? Probably with Expressions. private void RegisterEvent(EventHandler handler, Action<EventArgs> action) { handler += action; m_toUnsubscribe.Add(handler, action); } ... in Dispose() { foreach(var pair in m_toUnsubscribe) { pair.handler -= pair.action; } }

    Read the article

  • Wordpress Search Results in Order

    - by Brad Houston
    One of my clients websites, www.kevinsplants.co.uk is not showing the search results in alphabetical order, how do I go about ordering the results in alphabetical order? We are using the Shopp plugin and I believe its that plugin that is generating the results! Cheers, Brad case "orderby-list": if (isset($Shopp->Category->controls)) return false; if (isset($Shopp->Category->smart)) return false; $menuoptions = Category::sortoptions(); $title = ""; $string = ""; $default = $Shopp->Settings->get('default_product_order'); if (empty($default)) $default = "title"; if (isset($options['default'])) $default = $options['default']; if (isset($options['title'])) $title = $options['title']; if (value_is_true($options['dropdown'])) { if (isset($Shopp->Cart->data->Category['orderby'])) $default = $Shopp->Cart->data->Category['orderby']; $string .= $title; $string .= '<form action="'.esc_url($_SERVER['REQUEST_URI']).'" method="get" id="shopp-'.$Shopp->Category->slug.'-orderby-menu">'; if (!SHOPP_PERMALINKS) { foreach ($_GET as $key => $value) if ($key != 'shopp_orderby') $string .= '<input type="hidden" name="'.$key.'" value="'.$value.'" />'; } $string .= '<select name="shopp_orderby" class="shopp-orderby-menu">'; $string .= menuoptions($menuoptions,$default,true); $string .= '</select>'; $string .= '</form>'; $string .= '<script type="text/javascript">'; $string .= "jQuery('#shopp-".$Shopp->Category->slug."-orderby-menu select.shopp-orderby-menu').change(function () { this.form.submit(); });"; $string .= '</script>'; } else { if (strpos($_SERVER['REQUEST_URI'],"?") !== false) list($link,$query) = explode("\?",$_SERVER['REQUEST_URI']); $query = $_GET; unset($query['shopp_orderby']); $query = http_build_query($query); if (!empty($query)) $query .= '&'; foreach($menuoptions as $value => $option) { $label = $option; $href = esc_url($link.'?'.$query.'shopp_orderby='.$value); $string .= '<li><a href="'.$href.'">'.$label.'</a></li>'; } } return $string; break;

    Read the article

  • removing items from a generic List<t>

    - by frosty
    I have the following method, I wish to remove items from my collection that match the product Id. Seems fairly straight forward, but i get an exception. Basically my collection is getting out of sync. So what is the best way to remove an item from a collection. public void RemoveOrderItem(Model.Order currentOrder, int productId) { foreach (var orderItem in currentOrder.OrderItems) { if (orderItem.Product.Id == productId) { currentOrder.OrderItems.Remove(orderItem); } } } Exception Details: System.InvalidOperationException: Collection was modified; enumeration operation may not execute

    Read the article

  • How to parse a date from an SSIS Excel filename

    - by user327045
    I want to use the foreach container to iterate through a folder matching something like: "Filename_MMYYYY.xls". That's easy enough to do; but I can't seem to find a way to parse the MMYYYY from the filename and add it to a variable (or something) that i can use as a lookup field for my DimDate table. It seems possible with a flat file data source, but not an excel connection. I'm using Visual Studio 2005. Please help!

    Read the article

  • IEnumerator: Is it normal to have an empty Dispose method?

    - by C. Ross
    I'm writing an IEnumerator<T> class to iterate over a COM collection I'm wrappering. I've noticed that IEnumerator<T> extends IDisposable, so I'm required to implement the Dispose method. However, I can't think of anything I would put there, as I only have a reference to the collection (which I wouldn't want being disposed at the end of a foreach), and an int for the index. Is it normal to leave the Dispose method empty?

    Read the article

  • DataGridView cells not editable when using an outside thread call

    - by joslinm
    Hi, I'm not able to edit my datagridview cells when a number of identical calls takes place on another thread. Here's the situation: Dataset table is created in the main window The program receives in files and processes them on a background thread in class TorrentBuilder : BackgroundWorker creating an array objects of another class Torrent My program receives those objects from the BW result and adds them into the dataset The above happens either on my main window thread or in another thread: I have a separate thread watching a folder for files to come in, and when they do come in, they proceed to call TorrentBuilder.RunWorkerAsynch() from that thread, receive the result, and call an outside class that adds the Torrent objects into the table. When the files are received by the latter thread, the datagridview isn't editable. All of the values come up properly into the datagridview, but when I click on a cell to edit it: I can write letters and everything, but when I click out of it, it immediately reverts back to its original value. If I restart the program, I can edit the same cells just fine. If the values are freshly added from the main window thread, I can edit the cells just fine. The outside thread is called from my main window thread, and sits there in the background. I don't believe it to be ReadOnly because I would have gotten an exception. Here's some code: From my main window class: private void dataGridView_DragDrop(object sender, DragEventArgs e) { ArrayList al = new ArrayList(); string[] files = (string[])e.Data.GetData(DataFormats.FileDrop); foreach (string file in files) { string extension = Path.GetExtension(file); if (Path.GetExtension(file).Equals(".zip") || Path.GetExtension(file).Equals(".rar")) { foreach (string unzipped in dh.UnzipFile(file)) al.Add(unzipped); } else if (Path.GetExtension(file).Equals(".torrent")) { al.Add(file); } } dataGridViewProgressBar.Visible = true; tb.RunWorkerCompleted += new RunWorkerCompletedEventHandler(tb_DragDropCompleted); tb.ProgressChanged += new ProgressChangedEventHandler(tb_DragDropProgress); tb.RunWorkerAsync() } void tb_DragDropCompleted(object sender, RunWorkerCompletedEventArgs e) { data.AddTorrents((Torrent[])e.Result); builder.Dispose(); dh.MoveProcessedFiles(data); dataGridViewProgressBar.Visible = false; } From my outside Thread while (autocheck) { if (torrentFiles != null) { builder.RunWorkerAsync(torrentFiles); while (builder.IsBusy) Thread.Sleep(500); } } void builder_RunWorkerCompleted(object sender, System.ComponentModel.RunWorkerCompletedEventArgs e) { data.AddTorrents((Torrent[])e.Result); builder.Dispose(); dh.MoveProcessedFiles(xml); data.Save(); //Save just does an `AcceptChanges()` and saves to a XML file }

    Read the article

  • How to add jarray Object into JObject

    - by user2882431
    How to add JArray into JObject? I am getting an exception when changing the jarrayObj into JObject. parameterNames = "Test1,Test2,Test3"; JArray jarrayObj = new JArray(); foreach (string parameterName in parameterNames) { jarrayObj.Add(parameterName); } JObject ObjDelParams = new JObject(); ObjDelParams["_delete"] = jarrayObj; JObject UpdateAccProfile = new JObject( ObjDelParams, new JProperty("birthday", txtBday), new JProperty("email", txtemail)) I need output in this form: { "_delete": ["Test1","Test2","Test3"], "birthday":"2011-05-06", "email":"[email protected]" }

    Read the article

  • C# loop - break vs. continue

    - by Terrapin
    In a C# (feel free to answer for other languages) loop, what's the difference between break and continue as a means to leave the structure of the loop, and go to the next iteration? Example: foreach (DataRow row in myTable.Rows){ if (someConditionEvalsToTrue) { break; //what's the difference between this and continue ? //continue; }}

    Read the article

  • PHP Doctrine: filtering data which is already loaded?

    - by ropstah
    I'm new to Doctrine and ActiveRecord. How should I filter a table after it has been loaded? (i suppose this is preferred over sending multiple queries?) Is this 'good' or 'bad'? class UserTable extends Doctrine_Table { function filterByGroup($group) { $ut = new UserTable(); foreach($this as $u) { if($u->group = $group) $ut->add($u); } return $ut; } }

    Read the article

  • MVC 3 Nested EditorFor Templates

    - by Gordon Hickley
    I am working with MVC 3, Razor views and EditorFor templates. I have three simple nested models:- public class BillingMatrixViewModel { public ICollection<BillingRateRowViewModel> BillingRateRows { get; set; } public BillingMatrixViewModel() { BillingRateRows = new Collection<BillingRateRowViewModel>(); } } public class BillingRateRowViewModel { public ICollection<BillingRate> BillingRates { get; set; } public BillingRateRowViewModel() { BillingRates = new Collection<BillingRate>(); } } public class BillingRate { public int Id { get; set; } public int Rate { get; set; } } The BillingMatrixViewModel has a view:- @using System.Collections @using WIP_Data_Migration.Models.ViewModels @model WIP_Data_Migration.Models.ViewModels.BillingMatrixViewModel <table class="matrix" id="matrix"> <tbody> <tr> @Html.EditorFor(model => Model.BillingRateRows, "BillingRateRow") </tr> </tbody> </table> The BillingRateRow has an Editor Template called BillingRateRow:- @using System.Collections @model IEnumerable<WIP_Data_Migration.Models.ViewModels.BillingRateRowViewModel> @foreach (var item in Model) { <tr> <td> @item.BillingRates.First().LabourClass.Name </td> @Html.EditorFor(m => item.BillingRates) </tr> } The BillingRate has an Editor Template:- @model WIP_Data_Migration.Models.BillingRate <td> @Html.TextBoxFor(model => model.Rate, new {style = "width: 20px"}) </td> The markup produced for each input is:- <input name="BillingMatrix.BillingRateRows.item.BillingRates[0].Rate" id="BillingMatrix_BillingRateRows_item_BillingRates_0__Rate" style="width: 20px;" type="text" value="0"/> Notice the name and ID attributes the BillingRate indexes are handled nicely but the BillingRateRows has no index instead '.item.'. From my reasearch this is because the context has been pulled out due to the foreach loop, the loop shouldn't be necessary. I want to achieve:- <input name="BillingMatrix.BillingRateRows[0].BillingRates[0].Rate" id="BillingMatrix_BillingRateRows_0_BillingRates_0__Rate" style="width: 20px;" type="text" value="0"/> If I change the BillingRateRow View to:- @model WIP_Data_Migration.Models.ViewModels.BillingRateRowViewModel <tr> @Html.EditorFor(m => Model.BillingRates) </tr> It will throw an InvalidOperationException, 'model item passed into the dictionary is of type System.Collections.ObjectModel.Collection [BillingRateRowViewModel] but this dictionary required a type of BillingRateRowViewModel. Can anyone shed any light on this?

    Read the article

  • How to go to particular Item in IEnumerable

    - by Subhen
    Hi, I have Ienum which contains number Data inside it. Attached the snapShot of Viual Studio, Enum that Contains Data: Just to brief about the above image, eLevelData is the IEnumerable variable, in which I have my data . Now I want to go to the data at index 4 or 5, but I don't want to use foreach loop. Any suggestions please. Thanks, Subhen

    Read the article

  • Use of const in a method

    - by kouPhax
    In the following method, public void InspectList(IList<int> values) { if(values != null) { const string format = "Element At {0}"; foreach(int i in values) { Log(string.Format(format, i)); } } } Does the use of const provide any benefit over just declaring the string as a string? Woudl it not be interned anyway?

    Read the article

  • how properly remove item from list

    - by dygi
    // tmpClientList is List<Client> type if (txtboxClientName.Text != "") foreach (Client cli in tmpClientList) if (cli.Name != txtboxClientName.Text) tmpClientList.Remove(cli); Error: "Collection was modified; enumeration operation may not execute." How can i remove items from the list, in some simple way, without saving indexes of these items in another list or array, and removing them in another place in the code. Tried also RemoveAt(index) but it's exactly the same situation, modifying when loop runs.

    Read the article

  • How to compare DateTime Objects while looping through a list?

    - by Taniq
    I'm trying to loop through a list (csv) containing two fields; a name and a date. There are various duplicated names and various dates in the list. I'm trying to deduce for each name in the list, where there are multiple instances of the same name, which corresponding date is the latest. I realise, from looking at another answer, that I need to use the DateTime.Compare method which is fine, but my problem is working out which date is later. Once I know this I need to produce a file with unique names and the latest date relating to it. This is my first question which makes me a newbie. EDIT: Initially I thought it would be 'ok' to set the LatestDate object to a date that wouldn't show up in my file, therefore making any later dates in the file the LatestDate. Here's my coding so far: using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.IO; namespace flybe_overwriter { class Program { static DateTime currentDate; static DateTime latestDate = new DateTime(1000,1,1); static HashSet<string> uniqueNames = new HashSet<string>(); static string indexpath = @"e:\flybe test\indexing.csv"; static string[] indexlist = File.ReadAllLines(indexpath); static StreamWriter outputfile = new StreamWriter(@"e:\flybe test\match.csv"); static void Main(string[] args) { foreach (string entry in indexlist) { uniqueNames.Add(entry.Split(',')[0]); } HashSet<string>.Enumerator fenum = new HashSet<string>.Enumerator(); fenum = uniqueNames.GetEnumerator(); while (fenum.MoveNext()) { string currentName = fenum.Current; foreach (string line in indexlist) { currentDate = new DateTime(Convert.ToInt32(line.Split(',')[1].Substring(4, 4)), Convert.ToInt32(line.Split(',')[1].Substring(2, 2)), Convert.ToInt32(line.Split(',')[1].Substring(0, 2))); if (currentName == line.Split(',')[0]) { if(DateTime.Compare(latestDate.Date, currentDate.Date) < 1) { // Console.WriteLine(currentName + " " + latestDate.ToShortDateString() + " is earlier than " + currentDate.ToShortDateString()); } else if (DateTime.Compare(latestDate.Date, currentDate.Date) > 1) { // Console.WriteLine(currentName + " " + latestDate.ToShortDateString() + " is later than " + currentDate.ToShortDateString()); } else if (DateTime.Compare(latestDate.Date, currentDate.Date) == 0) { // Console.WriteLine(currentName + " " + latestDate.ToShortDateString() + " is the same as " + currentDate.ToShortDateString()); } } } } } } } Any help appreciated. Thanks.

    Read the article

  • Retrieve array key passed on value PHP

    - by Doodle
    I have the following array $group= array( [0] => 'apple', [1] => 'orange', [2] => 'gorilla' ); I run the array group through an for each function and when the loop hits values of gorilla I want it to spit out the index of gorilla foreach( $group as $key){ if ($key==gorilla){ echo //<------ the index of gorilla } }

    Read the article

  • Method-Object pairs in Java

    - by John Manak
    I'd like to create a list of method-object pairs. Each method is a function returning a boolean. Then: foreach(pair) { if method evaluates to true { do something with the object } } One way of modelling this that I can think of is to have a class Constraint with a method isValid() and for each constraint produce an anonymous class (overriding the isValid() method). I feel like there could be a nicer way. Can you think of any?

    Read the article

  • Stringbuilder ignores last space

    - by chead23
    I am initialising a StringBuilder as follows: StringBuilder builder = new StringBuilder("Symptoms are "); After this I loop through a list and add each string item to the end using foreach(var item in list) { builder.Append(item); } An example item would be something like "headache" but once i've appended it to "Symptoms are " and called builder.ToString() it shows: "Symptoms areHeadache...etc" as opposed to "Symptoms are Headache...etc" Why is it ignoring the space?

    Read the article

  • Chrome not displaying a div

    - by Kyle Sevenoaks
    Click here to see a simple example of what I want. It's really easy, but for some reason Google won't display the "subTotalCaption2" div. It's part of a foreach loop, if needed I can add other codes. There is nothing else in the rest of the css to mess with this, I have checked about 10 times. See it live at euroworker.no/order (add items to basket) In FF and Chrome. Thanks.

    Read the article

  • Limiting XML read to 5 records

    - by Jean
    Hello, I have a xml file with 100 records, but I want it to limit it to just 5 records for ($i=0;$i<=5;$i++) { foreach($xml-entry as $result){ if ($result->updated == $result->published) { } } } When I put in the above code, it display one record 5 times. Thanks Jean

    Read the article

< Previous Page | 122 123 124 125 126 127 128 129 130 131 132 133  | Next Page >