Is It Efficient To Use LINQ To Parse Strings?

Mar 18, 2011

I've been using LINQ so much in the last couple of weeks that when I had to write a one line function to remove < and > from a string, I found that I had written it as a LINQ query: [code] My question is, is it better to do it with LINQ as above or with StringBuilder as I've always done, as below: [code] Both work, the second one is easier to read, but the first one is designed for executing queries against arrays and other enumerables.

View 2 Replies


ADVERTISEMENT

Parse Names In Strings

Jun 11, 2011

I'm currently taking a class in VB 2008, with that said I am working with strings and had a quick question. I need to add code to parse the name when the user enters a name and clicks the Parse Name button, this code should work whether the user enters a first, middle, and last name or just a first and last name, before I get decimated by everyone, I am not asking anyone to do my homework because I already have a working solution to this, my question is to see if there is a "cleaner" or more "efficient" way to code this.

[Code]...

View 2 Replies

[2008] Parse FILTER Strings?

Jan 30, 2009

I've got a bunch of tag's that look like this

Quote:
?Me.CapabiltiesTreeView.SelectedNode.Tag.ToString
"VendorId=1 and Capability='Translation' and LanguageFrom='English' and

[code]....

View 5 Replies

[2008] Parse A Large Text File For Certain Strings

Feb 22, 2009

I am trying to parse a very large text file for certain strings. The text file is part of a level-making software for an old game I play. The text file basically contains all the information the level designer software needs, but the only important bit is the 'texture information'. Basically what I'm trying to create is a little program that parses the text files and shows the user a list of every texture in that text file. The problem is, the strings denoting textures are not really easy to find, and I can't think of any sensible and fast way to get them...

[Code]...

View 12 Replies

Wpf - Parse XML With Linq?

Jan 21, 2011

I have the following XML document which I would like to parse into a DataSet.

<?xml version="1.0" encoding="UTF-8" standalone="yes" ?>
<Response Status="OK">
<Item>
<Field Name="ID">767147519</Field>

[code]....

EDIT:Following one of the answers below, I have been attempting to implement an anonymous type in my Linq, however I keep encountering the error

Object reference not set to an instance of an object.

My updated code is as follows:

Dim name = From c In loaded.Descendants("Item") Select c Select sID = c.Element("Field").Attribute("Name").Value, sName = c.Attribute("ID").Value.FirstOrDefault
Dim Id As String = String.Empty

[code]....

I think this error means that the attribute ("ID") cannot be located, so I have attempted several variations of this with similar results.

View 12 Replies

C# - Look For Words In Strings With LINQ?

May 11, 2011

C# or VB.NET suggestion are welcome.

I have the following code:
Dim someText = "Stack Over Flow Community"
Dim someWord = "Over Community"

[code].....

View 4 Replies

VS 2008 Make LINQ Strings?

Feb 4, 2010

q1/ how can i convert a lowercase string to sentence case with LINQ, without losing my rtb formatting?

View 2 Replies

Dynamic Linq .OrderBy In .Net Not Accepting Strings?

Jun 20, 2012

I'm having a problem implementing Scott G's Dynamic.vb extension at [URL] in my vb solution. I've searched StackOverflow (80+ Q&As) and numerous other sites without much luck. I'm using VS 2010.I've included Dynamic.vb in a problem with no root namespace, and then added a reference to that project in my main one. I'm getting intellisense for 4 overloads (rather than 2) so I'm pretty certain that the extension is in scope.I was having a tough time with clauses, especially the OrderBy as Scott demonstrated. If I simply pass a string as Scott's VB example did I get the error "Overload resolution failed because no accessible 'OrderBy' can be called with these arguments."

The line of code is:

Dim FilteredComponentList = From Component As MX.Component In ComponentList.AsQueryable _
.OrderBy("Name")

So I found other references that stated to pass a Lambda expression. So I tried this and at least I get no error, even if the sort function still doesn't seem to work. Here is the code that compiles and executes.

Private Sub SortByColumn()
If Not cmbComponentFilter.SelectedItem.ToString = "All" Then
Dim FilteredComponentList = From Component As MX.Component In ComponentList.AsQueryable _

[code]....

When I interrogate the dgvComponents.Columns(e.ColumnIndex).Name it gives the objects property I wish to sort by, but the sort still isn't working. I'm concerned why I can't get Scott's implementation to work, but I've heard his keynotes and read his blogs, so I'm guessing the problem lies with my implementation.

I'd like either to work but need to understand why as well. Why doesn't passing a string work? Isn't the PARAMARRAY declared in the function optional?

View 1 Replies

Using Linq To Group, Order And Concatenate Strings

Jun 14, 2011

Suppose I have the following data

Key ID Data
A 1 Hello
A 2 World
B 2 Bar
B 1 Foo

I am looking to produce the result

A HelloWorld
B FooBar

I am struggling to get the syntax quite right - I was trying to use Aggregate, but I wasn't sure if I could (or should) use SelectMany

Dim data = result.Rows.
GroupBy(Function(r) r.Key).
Select(Function(g) g.OrderBy(Function(s) s.ID)).

[Code]....

View 4 Replies

.net - Convert Resultant Values To List Of Strings In Linq?

Oct 1, 2010

I'm having issues with returning a list of strings of the .Value of a Linq query:

Dim details = <Details>
<Vector size="5">
<Item>Syntactic Structures</Item>
<Item>Introduction</Item>
<Item>The Independence of Grammar</Item>

[Code]...

Is correct in that it returns the list of XElements I want (items 1 - 4, base 0), but I really just need a list of strings for the .Value of those XElements. Maybe I'm just dense here, but anything I've tried in the chapterTitles query isn't working (appending with .ToList.ToString, etc.). details.<Vector>.<Item>.Skip(1).Take(4).Value just returns the first XElement's value.

View 1 Replies

C# :: Aggregate Or Join Strings In Linq To Sql Query (SQL Server)?

Aug 6, 2010

Given a table like

ID | Name | City
1 | X | Y
2 | Z | Y

[code].....

View 2 Replies

How To Use LINQ To Find Matching Data Against A List Of Strings?

Jun 22, 2010

I have a specialized string dictionary of (string, string) (_RulesAndTheirDescriptions) that contains the name (key) and description (value) of methods in a given class. I currently do the following query to search for a match on the key or value and then bind that to a grid.

[Code]...

View 1 Replies

Way To Concatenate List Of Strings Into A Comma-separated Strings, Where Strings Are Members Of An Object?

Oct 16, 2009

Say I have a List(Of Tag) with Tag being an object. One member of Tag, Tag.Description, is a string, and I want to make a comma-separated concatenation of the Description members.Is there an easier way to do this than to read the Description members into a List(Of String) and then use the Join function?

View 2 Replies

.net - Write A Linq To Sql Query To Find Records Where Field Name Can Match One Of Dynamic Number Of Strings?

Mar 21, 2012

I have users check off lab facilities in a UI. I want to use linq to fetch corresponding records for all of the labs that they have checked off. Basically,

Dim myRecs = (From l As EpiData In myDataContext.EPIDatas Where l.facility= _
one of the checked labs

So basically, I need to write a linq query where the "strings" to match are determined at runtime. Is there any way to do this easily? I know that there is a library out there called dynamic LINQ, but (1) it's in C# and I'm writing in VB (2) I'm really just looking for a single, simple solution for this single case.

View 1 Replies

C# - Parse An Expression And Retrieve A Parse Tree?

Jun 8, 2012

I just want to parse simple expressions like IIF(FVAL(PFC) = TRUE, (IIF((ORGVAL(BAS, "2012/12/31") + ORGVAL(DA)) < 6500, (FVAL(BAS) + FVAL(DA)) * 12%, 780)), 0)`After parsing this I should be able to know what functions contains what parameters.

[Code]...

I'm stuck with .Net Framework 2.0, so no Linq or lambda expression goodies for me. Also I want to include the code in my custom library and not just reference it. Can anyone point me to some good library or code.

I just need to parse and not evaluate the expression and find what tokens are in use. After finding the tokens I need to change the expression string before parsing, like if the function ORGVAL is used then the parameter passed has has to be prefixed by an underscore. Like ORGVAL(BAS) will transform to ORGVAL(_BAS). Some functions can have tow parameters like ORGVAL(BAS, "2012/12/31") and this will transform to ORGVAL(_BAS, "2012/12/31")

NOTE: IF THERE ARE OTHER WAYS OF DOING IT PLEASE LET ME KNOW. I WOULD LOVE TO AVOID A PARSER AND LEXER.

View 3 Replies

'With ... End With' Really More Efficient?

Nov 4, 2010

It seems that when using With blocks in VB.NET, the resulting MSIL larger than w/o. So this leads me to ask, are With Blocks really more efficient? MSIL is what gets JITed into native machine code, so smaller code size should imply more efficient code, right?

[Code]...

View 5 Replies

Efficient Way To Add Validation ?

May 4, 2010

Where to add this validation, or if there is a more efficient way of doing it and where to put it?

CODE:

View 6 Replies

How To Use MVC Pattern Efficient

Aug 9, 2009

How to use MVC Pattern efficient?

View 8 Replies

More Efficient For Each Loops?

Jul 26, 2011

Is there a more efficient way of doing this code?

For Each row As DataRow In dt.Rows
Dim ts1 As String = row(0).ToString
For index As Integer = 1 To 9[code]....

View 2 Replies

Which Sort Is More Efficient?

Aug 26, 2011

just wondering which of these two sort methods would be more efficient movies.OrderBy(Function(m As Movie) m.Title)

[Code]...

View 1 Replies

VS 2008 Send An Object Instead Of Strings Which Includes Multiple Unsigned Integers And Strings

Aug 13, 2009

I am working on a UDP Client/Server, and currently i have them sending back and forth strings, which i convert to bytes, and then open the bytes to read. I want to now send an Object instead of those strings, which includes multiple unsigned integers and strings.

View 39 Replies

Asp.net - Which Function Is Faster And Efficient?

Jan 5, 2010

I need to verify if a certain user exist on my asp.net site.I want to know if which of these two functions is more efficient, faster and better compared to each other and why.

[Code]...

View 6 Replies

C# - Efficient Data Conversion Using .Net

Aug 1, 2009

I am working on an application that will need to read tons of records (close to 500,000) from one table and insert them into another set of tables in the same database. I though about using SSIS package for this but our DBAs don't want to use that. Now, I am thinking of a multi-threaded approach. I am thinking that I can have a few thread started that will read say (500) records at a time and insert them, then come back and read more.

Now, say I spawn off 3 threads of this application. The first thread reads 500 rows and starts processing them. Can I lock these rows that were already read so that the next thread does not pick them up? I am trying to find some articles regarding this on the internet, but perhaps I am not searching for the correct terms in Google.

View 6 Replies

Efficient Way To Sample Data?

Jul 1, 2010

I'd like to sample the data from the Arduino @ roughly 200Hz. Is there a more efficient way to do this than using a timer (which is what I am currently using)? Currently I am using[code]....

View 3 Replies

Is It More Efficient To Use UInteger Instead Of Integer

Nov 7, 2009

if there is no need for my variable to store negative values, is it more efficient to use UInteger instead of Integer? both are 4bytes and i've got a feeling unsigned works faster though i'm nt sure about it. note that the range of my variable is 0 to 2147483647, hence i could use a UInt32 or Int32 and both would give me the same result so i'm wondering about optimum performance.

View 7 Replies

More Efficient Way To Create 1 MB File?

Jun 22, 2010

I have been reading books trying to learn .net on my own. I am working on an exercise that asks me to create a 1MB file. what i have below does work, but it seems to me there would be a more efficeient way. It seems like what i am doing would cause a lot of overhead. making a 1MB file easier than what i have?[code]...

View 2 Replies

Most Efficient Way To Initialize A Table?

Jul 28, 2009

I have a program that must initialize a table that is usually about 10-15 thousand records. I have attempted several means to empty the records from it, but it always takes several minutes to accomplish the task or in some cases like a 'bindingsource.clear' command, doesn't work at all. I currently have it working using a simple loop to go through each record at a time and 'removecurrent'. but this seems extremely inefficient and it is quite slow.The real time consumer seems to come in with the tableadapter.update and tableadapter.fill that happens after the loop.[code]

View 6 Replies

Fastest And Efficient Way Of Creating File In .NET

Jul 28, 2010

I've an arraylist having 30000 items in it, what's the best way of creating a text file on the fly from an ASP.NEt page? Currently I'm using the code below but it times out with large data,[code]

View 3 Replies

Asp.net - Efficient Way To Combine Two List(Of String)?

Mar 16, 2010

Let's say I've got: Dim los1 as New List(Of String) los1.Add("Some value")

Dim los2 as New List(Of String) los2.Add("More values")

What would be the most efficient way to combine the two into a single List(Of String)?

Edit: While I love the solutions everyone has provided, I probably should have also mentioned I'm stuck using the .NET 2.0 framework.

View 4 Replies

Asp.net - More Efficient Way Of Saving A Dataset To SQL Database?

Nov 9, 2011

I am looping through my dataset to save my database, I thought this might not be the best way. Is there a more resource efficient of doing it?

For i As Integer = 0 To CO.Tables("CO_Del").Rows.Count - 1 'CO is my DataSet
dbCommand.Parameters.Clear()
AddInParameter(dbCommand, "@IsDelete", DbType.Boolean, 0, DBNull.Value)[code].......

View 3 Replies







Copyrights 2005-15 www.BigResource.com, All rights reserved