Solved

linq and formatnumber

Posted on 2009-05-15
4
479 Views
Last Modified: 2013-11-11
Hi,
How do I get this to work?

.pricew4wd = (From p In q...<price> _
                  Where (p.@vehicle = "yes") _
                  Select (pricew4wd = p.Value.FirstOrDefault(), _      
                  FormatNumber(pricew4wd, 2)), _

I am getting a syntax error.

Thanks
Tania
0
Comment
Question by:Tania_Farmer
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
4 Comments
 
LVL 63

Expert Comment

by:Fernando Soto
ID: 24395121
Is this Linq to XML? If so can you post the XML and the full query that you are using so that we can determin where the syntax error is. If it is NOT Linq to XML can you give more details.
0
 
LVL 63

Expert Comment

by:Fernando Soto
ID: 24395868
Something like this should work but without seeing the whole query and code around it, it is hard to tell.

pricew4wd = (From p In q...<price> _
                        Where p.@vehicle = "yes" _
                        Select pricew4wd = p.Value).FirstOrDefault()
                   
Dim numFormatted As Single = FormatNumber(pricew4wd, 2))
0
 

Author Comment

by:Tania_Farmer
ID: 24395956
Hi,
Thanks - sorry missed your reply.

<product code="lr" title="4wd Bush Driving">
      <duration>1 Day</duration>
      <visible>true</visible>
      <prices>
        <price vehicle="yes" >245</price>
        <price vehicle="no">180</price>
      </prices>
</product>

I got this working - is it ok to use structurally?

Select pricewo4wd = Formatnumber(p.Value,2)).FirstOrDefault(), _


T
0
 
LVL 63

Accepted Solution

by:
Fernando Soto earned 500 total points
ID: 24396059
From what you are showing of the statement that should be fine as well.
0

Featured Post

[Webinar] Code, Load, and Grow

Managing multiple websites, servers, applications, and security on a daily basis? Join us for a webinar on May 25th to learn how to simplify administration and management of virtual hosts for IT admins, create a secure environment, and deploy code more effectively and frequently.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Recently while returning home from work my wife (another .NET developer) was murmuring something. On further poking she said that she has been assigned a task where she has to serialize and deserialize objects and she is afraid of serialization. Wha…
More often than not, we developers are confronted with a need: a need to make some kind of magic happen via code. Whether it is for a client, for the boss, or for our own personal projects, the need must be satisfied. Most of the time, the Framework…

732 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question