Good tutorial for working with XML

D

Dale Atkin

I've spent the last couple of days digging through MSDN help, and googling
various pages, trying to understand exactly how VB.NET deals with XML. I've
made some progress, but I feel like I'm missing something fundamental. Can
any one point me in the direction of some *good* tutorials that might be
helpful? Everything I've found so far is either way too simple, or seems to
assume that I know things that I don't, so I get hung up on the details.

For reference, basically what I'm trying to do is read and write some fairly
basic XML files (of my own creation) to disk. I've written some routines
already to do this, but I'd prefer to use the built in XML handling
functions, as they are probably a lot more robust than what ever I might
code up in an afternoon (I can already think of a few things a user could do
that will break my code, and I don't feel like fixing them, as I'm sure
there are a dozen other things which I've not thought of yet).

The XML files look something like the below. Basically, they are 'maps' of
an image file. Each slide can contain multiple draw objects (<do>). Each
draw object contains a list of attributes.

<slide>
<name>Name of slide</name>
<longdesc>Description of slide</longdesc>
<do>
<name>Feature name</name>
<id>Feature ID</id>
<type>1</type>
<coords>
1125,1021; 1370,946; 2019,885; 2189,899; ;
</coords>
</do>
<do>
<name>Feature Name 2</name>
<id>ID 2</id>
<type>1</type>
<coords>
2960,1548; 3042,1386; 3165,1247; 3342,1108;
</coords>
</do>
</slide>

Ideally, what I'd like to be able to do, is read in the file, and easily
access the data. I'm able to access the data now, using the 'immediate'
window, but the pattern just isn't logical to me.

Really what I'd like to be able to do, is say something like
Slidename = XML.slide.name
Slidedesc = XML.slide.longdesc
draw0.name = XML.slide.do(0).name

etc.

But I seem to be getting bogged down trying to understand how VB sees XML.
Obviously the above is 'ideal world' stuff, I'm fine access the data in some
other way, provided it makes sense to me. Right now, I feel like I'm trying
to fit a square peg in to a round hole. (Oh, I should mention, I'm free for
the moment to modify the XML format as much as I please, if a modification
would make things more understandable.)
 
D

dunawayc

I've spent the last couple of days digging through MSDN help, and googling
various pages, trying to understand exactly how VB.NET deals with XML. I've
made some progress, but I feel like I'm missing something fundamental. Can
any one point me in the direction of some *good* tutorials that might be
helpful? Everything I've found so far is either way too simple, or seems to
assume that I know things that I don't, so I get hung up on the details.

For reference, basically what I'm trying to do is read and write some fairly
basic XML files (of my own creation) to disk. I've written some routines
already to do this, but I'd prefer to use the built in XML handling
functions, as they are probably a lot more robust than what ever I might
code up in an afternoon (I can already think of a few things a user could do
that will break my code, and I don't feel like fixing them, as I'm sure
there are a dozen other things which I've not thought of yet).

The XML files look something like the below. Basically, they are 'maps' of
an image file. Each slide can contain multiple draw objects (<do>). Each
draw object contains a list of attributes.

<slide>
<name>Name of slide</name>
<longdesc>Description of slide</longdesc>
<do>
<name>Feature name</name>
<id>Feature ID</id>
<type>1</type>
<coords>
1125,1021; 1370,946; 2019,885; 2189,899; ;
</coords>
</do>
<do>
<name>Feature Name 2</name>
<id>ID 2</id>
<type>1</type>
<coords>
2960,1548; 3042,1386; 3165,1247; 3342,1108;
</coords>
</do>
</slide>

Ideally, what I'd like to be able to do, is read in the file, and easily
access the data. I'm able to access the data now, using the 'immediate'
window, but the pattern just isn't logical to me.

Really what I'd like to be able to do, is say something like
Slidename = XML.slide.name
Slidedesc = XML.slide.longdesc
draw0.name = XML.slide.do(0).name

etc.

But I seem to be getting bogged down trying to understand how VB sees XML.
Obviously the above is 'ideal world' stuff, I'm fine access the data in some
other way, provided it makes sense to me. Right now, I feel like I'm trying
to fit a square peg in to a round hole. (Oh, I should mention, I'm free for
the moment to modify the XML format as much as I please, if a modification
would make things more understandable.)

I like to use classes to model data and use the Xml Serializer to
create the xml. Here is a sample based on what you posted:

It creates the following Xml file:


<?xml version="1.0" encoding="utf-8"?>
<Slide xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<Name>Slide 1</Name>
<LongDescription>Long Description of Slide 1</LongDescription>
<DrawObjects>
<DrawObject>
<Name>Draw Object Name</Name>
<Id>Id 1</Id>
<Type>1</Type>
<Coordinates>
<Coordinate>
<X>123.45</X>
<Y>456.78</Y>
</Coordinate>
<Coordinate>
<X>123.45</X>
<Y>456.78</Y>
</Coordinate>
</Coordinates>
</DrawObject>
</DrawObjects>
</Slide>


You call it like this:



Sub Main()

Dim s As New Slide
s.Name = "Slide 1"
s.LongDescription = "Long Description of Slide 1"

Dim do1 As New DrawObject
do1.Id = "Id 1"
do1.Name = "Draw Object Name"
do1.Type = 1

Dim c1 As New Coordinate
c1.X = 123.45
c1.Y = 456.78

do1.Coordinates.Add(c1)

Dim c2 As New Coordinate
c2.X = 123.45
c2.Y = 456.78

do1.Coordinates.Add(c2)

s.DrawObjects.Add(do1)

Slide.Save("c:\test.xml", s)

Dim s2 As Slide = Slide.Load("c:\test.xml")

Console.ReadLine()
End Sub




Imports System.Collections.Generic
Imports System.IO
Imports System.Xml.Serialization

<Serializable()> _
Public Class Slide

Private _name As String
Private _longDescription As String
Private _drawObjects As List(Of DrawObject)

Public Sub New()
_drawObjects = New List(Of DrawObject)
End Sub

Public Property Name() As String
Get
Return _name
End Get
Set(ByVal Value As String)
_name = Value
End Set
End Property

Public Property LongDescription() As String
Get
Return _longDescription
End Get
Set(ByVal Value As String)
_longDescription = Value
End Set
End Property

Public Property DrawObjects() As List(Of DrawObject)
Get
Return _drawObjects
End Get
Set(ByVal Value As List(Of DrawObject))
_drawObjects = Value
End Set
End Property

Public Shared Function Load(ByVal filename As String) As Slide
Dim result As Slide

Dim xSer As New XmlSerializer(GetType(Slide))
Using rdr As New StreamReader(filename)
result = DirectCast(xSer.Deserialize(rdr), Slide)
End Using

Return result
End Function

Public Shared Sub Save(ByVal filename As String, ByVal obj As
Slide)
Dim xSer As New XmlSerializer(GetType(Slide))
Using wrt As New StreamWriter(filename)
xSer.Serialize(wrt, obj)
End Using
End Sub

End Class

<Serializable()> _
Public Class DrawObject
Private _name As String
Private _id As String
Private _type As Integer
Private _coordinates As List(Of Coordinate)

Public Sub New()
_coordinates = New List(Of Coordinate)
End Sub

Public Property Name() As String
Get
Return _name
End Get
Set(ByVal Value As String)
_name = Value
End Set
End Property

Public Property Id() As String
Get
Return _id
End Get
Set(ByVal Value As String)
_id = Value
End Set
End Property

Public Property Type() As Integer
Get
Return _type
End Get
Set(ByVal Value As Integer)
_type = Value
End Set
End Property

Public Property Coordinates() As List(Of Coordinate)
Get
Return _coordinates
End Get
Set(ByVal Value As List(Of Coordinate))
_coordinates = Value
End Set
End Property

End Class

<Serializable()> _
Public Class Coordinate
Private _x As Double
Private _y As Double

Public Property X() As Double
Get
Return _x
End Get
Set(ByVal Value As Double)
_x = Value
End Set
End Property

Public Property Y() As Double
Get
Return _y
End Get
Set(ByVal Value As Double)
_y = Value
End Set
End Property
End Class



I hope this will help you,

Chris
 
D

dunawayc

I've spent the last couple of days digging through MSDN help, and googling
various pages, trying to understand exactly how VB.NET deals with XML. I've
made some progress, but I feel like I'm missing something fundamental. Can
any one point me in the direction of some *good* tutorials that might be
helpful? Everything I've found so far is either way too simple, or seems to
assume that I know things that I don't, so I get hung up on the details.

For reference, basically what I'm trying to do is read and write some fairly
basic XML files (of my own creation) to disk. I've written some routines
already to do this, but I'd prefer to use the built in XML handling
functions, as they are probably a lot more robust than what ever I might
code up in an afternoon (I can already think of a few things a user could do
that will break my code, and I don't feel like fixing them, as I'm sure
there are a dozen other things which I've not thought of yet).

The XML files look something like the below. Basically, they are 'maps' of
an image file. Each slide can contain multiple draw objects (<do>). Each
draw object contains a list of attributes.

<slide>
<name>Name of slide</name>
<longdesc>Description of slide</longdesc>
<do>
<name>Feature name</name>
<id>Feature ID</id>
<type>1</type>
<coords>
1125,1021; 1370,946; 2019,885; 2189,899; ;
</coords>
</do>
<do>
<name>Feature Name 2</name>
<id>ID 2</id>
<type>1</type>
<coords>
2960,1548; 3042,1386; 3165,1247; 3342,1108;
</coords>
</do>
</slide>

Ideally, what I'd like to be able to do, is read in the file, and easily
access the data. I'm able to access the data now, using the 'immediate'
window, but the pattern just isn't logical to me.

Really what I'd like to be able to do, is say something like
Slidename = XML.slide.name
Slidedesc = XML.slide.longdesc
draw0.name = XML.slide.do(0).name

etc.

But I seem to be getting bogged down trying to understand how VB sees XML.
Obviously the above is 'ideal world' stuff, I'm fine access the data in some
other way, provided it makes sense to me. Right now, I feel like I'm trying
to fit a square peg in to a round hole. (Oh, I should mention, I'm free for
the moment to modify the XML format as much as I please, if a modification
would make things more understandable.)

I like to use classes to model data and use the Xml Serializer to
create the xml. Here is a sample based on what you posted:

It creates the following Xml file:


<?xml version="1.0" encoding="utf-8"?>
<Slide xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<Name>Slide 1</Name>
<LongDescription>Long Description of Slide 1</LongDescription>
<DrawObjects>
<DrawObject>
<Name>Draw Object Name</Name>
<Id>Id 1</Id>
<Type>1</Type>
<Coordinates>
<Coordinate>
<X>123.45</X>
<Y>456.78</Y>
</Coordinate>
<Coordinate>
<X>123.45</X>
<Y>456.78</Y>
</Coordinate>
</Coordinates>
</DrawObject>
</DrawObjects>
</Slide>


You call it like this:



Sub Main()

Dim s As New Slide
s.Name = "Slide 1"
s.LongDescription = "Long Description of Slide 1"

Dim do1 As New DrawObject
do1.Id = "Id 1"
do1.Name = "Draw Object Name"
do1.Type = 1

Dim c1 As New Coordinate
c1.X = 123.45
c1.Y = 456.78

do1.Coordinates.Add(c1)

Dim c2 As New Coordinate
c2.X = 123.45
c2.Y = 456.78

do1.Coordinates.Add(c2)

s.DrawObjects.Add(do1)

Slide.Save("c:\test.xml", s)

Dim s2 As Slide = Slide.Load("c:\test.xml")

Console.ReadLine()
End Sub




Imports System.Collections.Generic
Imports System.IO
Imports System.Xml.Serialization

<Serializable()> _
Public Class Slide

Private _name As String
Private _longDescription As String
Private _drawObjects As List(Of DrawObject)

Public Sub New()
_drawObjects = New List(Of DrawObject)
End Sub

Public Property Name() As String
Get
Return _name
End Get
Set(ByVal Value As String)
_name = Value
End Set
End Property

Public Property LongDescription() As String
Get
Return _longDescription
End Get
Set(ByVal Value As String)
_longDescription = Value
End Set
End Property

Public Property DrawObjects() As List(Of DrawObject)
Get
Return _drawObjects
End Get
Set(ByVal Value As List(Of DrawObject))
_drawObjects = Value
End Set
End Property

Public Shared Function Load(ByVal filename As String) As Slide
Dim result As Slide

Dim xSer As New XmlSerializer(GetType(Slide))
Using rdr As New StreamReader(filename)
result = DirectCast(xSer.Deserialize(rdr), Slide)
End Using

Return result
End Function

Public Shared Sub Save(ByVal filename As String, ByVal obj As
Slide)
Dim xSer As New XmlSerializer(GetType(Slide))
Using wrt As New StreamWriter(filename)
xSer.Serialize(wrt, obj)
End Using
End Sub

End Class

<Serializable()> _
Public Class DrawObject
Private _name As String
Private _id As String
Private _type As Integer
Private _coordinates As List(Of Coordinate)

Public Sub New()
_coordinates = New List(Of Coordinate)
End Sub

Public Property Name() As String
Get
Return _name
End Get
Set(ByVal Value As String)
_name = Value
End Set
End Property

Public Property Id() As String
Get
Return _id
End Get
Set(ByVal Value As String)
_id = Value
End Set
End Property

Public Property Type() As Integer
Get
Return _type
End Get
Set(ByVal Value As Integer)
_type = Value
End Set
End Property

Public Property Coordinates() As List(Of Coordinate)
Get
Return _coordinates
End Get
Set(ByVal Value As List(Of Coordinate))
_coordinates = Value
End Set
End Property

End Class

<Serializable()> _
Public Class Coordinate
Private _x As Double
Private _y As Double

Public Property X() As Double
Get
Return _x
End Get
Set(ByVal Value As Double)
_x = Value
End Set
End Property

Public Property Y() As Double
Get
Return _y
End Get
Set(ByVal Value As Double)
_y = Value
End Set
End Property
End Class



I hope this will help you,

Chris
 
T

Tom Shelton

I've spent the last couple of days digging through MSDN help, and googling
various pages, trying to understand exactly how VB.NET deals with XML. I've
made some progress, but I feel like I'm missing something fundamental. Can
any one point me in the direction of some *good* tutorials that might be
helpful? Everything I've found so far is either way too simple, or seems to
assume that I know things that I don't, so I get hung up on the details.

For reference, basically what I'm trying to do is read and write some fairly
basic XML files (of my own creation) to disk. I've written some routines
already to do this, but I'd prefer to use the built in XML handling
functions, as they are probably a lot more robust than what ever I might
code up in an afternoon (I can already think of a few things a user could do
that will break my code, and I don't feel like fixing them, as I'm sure
there are a dozen other things which I've not thought of yet).

The XML files look something like the below. Basically, they are 'maps' of
an image file. Each slide can contain multiple draw objects (<do>). Each
draw object contains a list of attributes.

<slide>
<name>Name of slide</name>
<longdesc>Description of slide</longdesc>
<do>
<name>Feature name</name>
<id>Feature ID</id>
<type>1</type>
<coords>
1125,1021; 1370,946; 2019,885; 2189,899; ;
</coords>
</do>
<do>
<name>Feature Name 2</name>
<id>ID 2</id>
<type>1</type>
<coords>
2960,1548; 3042,1386; 3165,1247; 3342,1108;
</coords>
</do>
</slide>

Ideally, what I'd like to be able to do, is read in the file, and easily
access the data. I'm able to access the data now, using the 'immediate'
window, but the pattern just isn't logical to me.

Really what I'd like to be able to do, is say something like
Slidename = XML.slide.name
Slidedesc = XML.slide.longdesc
draw0.name = XML.slide.do(0).name

etc.

But I seem to be getting bogged down trying to understand how VB sees XML.
Obviously the above is 'ideal world' stuff, I'm fine access the data in some
other way, provided it makes sense to me. Right now, I feel like I'm trying
to fit a square peg in to a round hole. (Oh, I should mention, I'm free for
the moment to modify the XML format as much as I please, if a modification
would make things more understandable.)

The best method really depends on the version of VB.NET your using? If your
using a version before VB2008, then you want to look at the System.Xml
classes (and there are differences depending on if your using 2005 or 2003 or
earlier). If you are using VB2008, then you want to look at LINQ-To-XML and
the integrated xml language features of VB9.
 
T

Tom Shelton

I've spent the last couple of days digging through MSDN help, and googling
various pages, trying to understand exactly how VB.NET deals with XML. I've
made some progress, but I feel like I'm missing something fundamental. Can
any one point me in the direction of some *good* tutorials that might be
helpful? Everything I've found so far is either way too simple, or seems to
assume that I know things that I don't, so I get hung up on the details.

For reference, basically what I'm trying to do is read and write some fairly
basic XML files (of my own creation) to disk. I've written some routines
already to do this, but I'd prefer to use the built in XML handling
functions, as they are probably a lot more robust than what ever I might
code up in an afternoon (I can already think of a few things a user could do
that will break my code, and I don't feel like fixing them, as I'm sure
there are a dozen other things which I've not thought of yet).

The XML files look something like the below. Basically, they are 'maps' of
an image file. Each slide can contain multiple draw objects (<do>). Each
draw object contains a list of attributes.

<slide>
<name>Name of slide</name>
<longdesc>Description of slide</longdesc>
<do>
<name>Feature name</name>
<id>Feature ID</id>
<type>1</type>
<coords>
1125,1021; 1370,946; 2019,885; 2189,899; ;
</coords>
</do>
<do>
<name>Feature Name 2</name>
<id>ID 2</id>
<type>1</type>
<coords>
2960,1548; 3042,1386; 3165,1247; 3342,1108;
</coords>
</do>
</slide>

Ideally, what I'd like to be able to do, is read in the file, and easily
access the data. I'm able to access the data now, using the 'immediate'
window, but the pattern just isn't logical to me.

Really what I'd like to be able to do, is say something like
Slidename = XML.slide.name
Slidedesc = XML.slide.longdesc
draw0.name = XML.slide.do(0).name

etc.

But I seem to be getting bogged down trying to understand how VB sees XML.
Obviously the above is 'ideal world' stuff, I'm fine access the data in some
other way, provided it makes sense to me. Right now, I feel like I'm trying
to fit a square peg in to a round hole. (Oh, I should mention, I'm free for
the moment to modify the XML format as much as I please, if a modification
would make things more understandable.)

The best method really depends on the version of VB.NET your using? If your
using a version before VB2008, then you want to look at the System.Xml
classes (and there are differences depending on if your using 2005 or 2003 or
earlier). If you are using VB2008, then you want to look at LINQ-To-XML and
the integrated xml language features of VB9.
 
D

Dale Atkin

The best method really depends on the version of VB.NET your using? If
your
using a version before VB2008, then you want to look at the System.Xml
classes (and there are differences depending on if your using 2005 or 2003
or
earlier). If you are using VB2008, then you want to look at LINQ-To-XML
and
the integrated xml language features of VB9.

Good point... I should have mentioned I'm using VS2009 Pro (although I'm a
relative newbie on it, having just made the switch from VB6 about 3 weeks
ago now).

Dale
 
D

Dale Atkin

The best method really depends on the version of VB.NET your using? If
your
using a version before VB2008, then you want to look at the System.Xml
classes (and there are differences depending on if your using 2005 or 2003
or
earlier). If you are using VB2008, then you want to look at LINQ-To-XML
and
the integrated xml language features of VB9.

Good point... I should have mentioned I'm using VS2009 Pro (although I'm a
relative newbie on it, having just made the switch from VB6 about 3 weeks
ago now).

Dale
 
D

Dale Atkin

I like to use classes to model data and use the Xml Serializer to
create the xml. Here is a sample based on what you posted:

' I take it, this here is the 'meat' of the code... I'm going to have to
play with this somewhat
Public Shared Function Load(ByVal filename As String) As Slide
Dim result As Slide

Dim xSer As New XmlSerializer(GetType(Slide))
Using rdr As New StreamReader(filename)
result = DirectCast(xSer.Deserialize(rdr), Slide)
End Using

Return result
End Function

Public Shared Sub Save(ByVal filename As String, ByVal obj As
Slide)
Dim xSer As New XmlSerializer(GetType(Slide))
Using wrt As New StreamWriter(filename)
xSer.Serialize(wrt, obj)
End Using
End Sub

Very interesting... I'm going to have to play with this somewhat... I
already have this stuff encapsulted in a class. This seems like it might be
what I'm looking for (although it almost seems like cheating, if its as easy
as it looks ;) ).

Private _coordinates As List(Of Coordinate)
You can tell I've been away from the developments in the language for a
while... This seems like a much better way to declare things than the way
I've been doing it. From syntax, I assume this is equivalent to a
collection, but restricted in type to the given datatype?
I hope this will help you,

At the very least, its interesting. Definitely worth playing around with
some of this stuff. I'll let you know how I make out.

Dale
 
D

Dale Atkin

I like to use classes to model data and use the Xml Serializer to
create the xml. Here is a sample based on what you posted:

' I take it, this here is the 'meat' of the code... I'm going to have to
play with this somewhat
Public Shared Function Load(ByVal filename As String) As Slide
Dim result As Slide

Dim xSer As New XmlSerializer(GetType(Slide))
Using rdr As New StreamReader(filename)
result = DirectCast(xSer.Deserialize(rdr), Slide)
End Using

Return result
End Function

Public Shared Sub Save(ByVal filename As String, ByVal obj As
Slide)
Dim xSer As New XmlSerializer(GetType(Slide))
Using wrt As New StreamWriter(filename)
xSer.Serialize(wrt, obj)
End Using
End Sub

Very interesting... I'm going to have to play with this somewhat... I
already have this stuff encapsulted in a class. This seems like it might be
what I'm looking for (although it almost seems like cheating, if its as easy
as it looks ;) ).

Private _coordinates As List(Of Coordinate)
You can tell I've been away from the developments in the language for a
while... This seems like a much better way to declare things than the way
I've been doing it. From syntax, I assume this is equivalent to a
collection, but restricted in type to the given datatype?
I hope this will help you,

At the very least, its interesting. Definitely worth playing around with
some of this stuff. I'll let you know how I make out.

Dale
 
N

nak

Hey Cor,
You sound now like older guys who could not go on with the progress.

Linq is like WPF like WCF like Personal Webbrowser '98 like FrontPage '98
like IE 4.0 like Win3.11

Well not necessarily, I'm not stuck in my ways, in fact I always try out
the latest methodologies to see if they will make my code any slicker. But
one thing I'm not afraid of doing is writing a load of code to get the job
done properly, LINQ can save time, but that doesn't mean it should be used
imo. It's not doing anything that couldn't be done before, it's just doing
it quicker, and as for generics??! LOL! That's going back a whole load of
steps.
You tell it is not your way, and at a certain moment you see you are busy
in the newsgroup where those old VB6 developers are in nicely talking
about all the faults Microsoft has made

LOL, VB6 developers constantly cussing .NET? Yeah but that is quite
different from cussing a specific element added to a language to make things
"quicker" to write, but not necessarily "better" to write. The second MS
sort out debugging a huge LINQ statement, into a more manageable process,
I'll start playing with it again, but as for now I just remove any LINQ I
come across (providing I have time).
I don't like Linq either, but I hope that it has progress and that by
instance the datasource from Linq to SQL becomes more manageable.
As that kind of things not happen (I don't mean in version '10 but the
next because that takes always at least 2 versions) then I know it will
have a short live.

Hopefully! But then MS seem to be pulling allot of things lately, for
some odd reason. 2 things I've only just found out about (a bit slow I
know), but Live Messenger 2009 API, and Managed DirectX. Quite why Managed
DirectX was pulled really confuses me, especially as DirectX is accessible
through WPF, I was kind of presuming it would use the managed interface, I
guess not?

Anyways that's another story entirely.
But at the moment I have beside an English-Dutch dictionary the book Linq
in Action on my desk.

LOL! Keep hold of it, it might be an antique one day ;) When people
say "LINQ what is that?"...

Nick.
 
T

Tom Shelton

Hey Cor,


Well not necessarily, I'm not stuck in my ways, in fact I always try out
the latest methodologies to see if they will make my code any slicker. But
one thing I'm not afraid of doing is writing a load of code to get the job
done properly, LINQ can save time, but that doesn't mean it should be used
imo. It's not doing anything that couldn't be done before, it's just doing
it quicker, and as for generics??! LOL! That's going back a whole load of
steps.

You think generics are a step backwards? Wow. Safer code is a step
backwards? Faster code is a step backwards? Interesting.
 
N

nak

Hi Tom,

You think generics are a step backwards? Wow. Safer code is a step
backwards? Faster code is a step backwards? Interesting.

I'm referring to the generic variables declared during LINQ statements.
Maybe I don't have the name correct, "Implicitly Typed Local Variables", aka
"var". I don't like it at all.

Personally I prefer everything to be explicitly declared, I'm very anal
with my coding in that respect lol!

Nick.
 
T

Tom Shelton

Hi Tom,



I'm referring to the generic variables declared during LINQ statements.
Maybe I don't have the name correct, "Implicitly Typed Local Variables", aka
"var". I don't like it at all.

Ah... Now I get you.
Personally I prefer everything to be explicitly declared, I'm very anal
with my coding in that respect lol!

Again, I can't say I wholly disagree with you on this. I personally find type
automatic type inference to be a bit distasteful.
 
C

Cor Ligthert[MVP]

Hi Nak,

There was in previous time some guys which endless message threads who said
the Option Strict should be off

Do you remember who they were (I know that Armin was against this).

This option Infer is the solution to do what this guys wanted and in the
same way create strongly typed code

:)

Cor
 
N

nak

Hey Cor,
There was in previous time some guys which endless message threads who
said the Option Strict should be off

Do you remember who they were (I know that Armin was against this).

LOL! *shuffles feet*

I may have been one also as I never really used it until I started
mixing up code with other developers, then it came into its own and I make
sure I turn it on when I create a new project each time. The only times I
have disabled it as of late is when referencing COM objects with no
interface, then only for the class level.

I remember that discussion well! lol! :D

Nick.
 
D

David Glienna

The best tool for the job works in my book, and LINQ to XML does all the
work for you, if you can figure out the LINQ query. I've used it in a few
projects, and like LINQ to SQL as well.
 
T

Tom Shelton

The best tool for the job works in my book, and LINQ to XML does all the
work for you, if you can figure out the LINQ query. I've used it in a few
projects, and like LINQ to SQL as well.

I like linq to xml very much - but, linq to sql, not so much. It's slow, and
since I already have a pretty decent DAL in place, it doesn't seem to buy me
much.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top