From the course: .NET Essentials: LINQ for XML

Unlock the full course today

Join today to access over 22,500 courses taught by industry experts or purchase this course individually.

Use SetValue to set with non-string data

Use SetValue to set with non-string data - .NET Tutorial

From the course: .NET Essentials: LINQ for XML

Start my 1-month free trial

Use SetValue to set with non-string data

- [Instructor] Earlier in this chapter, we looked at the value property. It is read-write property of type string. So that means that if you have a variable, like I do here on line nine, I have a decimal variable, and I would like to assign that to the value property, like I'm doing here on line 14 and 13, I can't do it directly. You can see that this is a type string. When I hover over this error, I see that it can not implicitly convert type decimal to string. So as a programmer, you know how to deal with this. You would convert this to a string, in one way or another. Here's a simple way of doing that. But if you don't want to go through this process of converting it to a string, there is the set value method that does that automatically for you. So let me comment out these two again. And like it the Syntech is set value. It takes an object as a parameter. And essentially what this method does is it calls two…

Contents