There are times when we need to dynamically convert/parse the object from its string value to its type.
Below is the generic converter code which we can use instead of creating method for each type.
var strVal = "StringValueofObject";
var converter = TypeDescriptor.GetConverter(typeof(temp));
temp = (SomeType)converter.ConvertFromString(strVal);
It basically gets the TypeConverter for the specified type and calls its method ConvertFromString. If we want to have similar functionality for our classes then we can create TypeConverters for our own custom classes.
So its being a while working on WEB API and still it surprises with me everyday with the new way I can extend it. In this article I would like to share TypeConverters and ModelBinders, how they fit into everyday work and how they can make the API access easier for end clients.
Nullables are the special value types which can contain their range of values along with null as an additional value.
Nullables are very useful especially when we deal with database or external systems where there is a possibility of empty or null value for an expected value type.
Lets see how nullables can be created and used.
In this post I would be discussing about the popular way of testing i.e. Mocking. Lets see what is mocking, why is it important and how do we implement this using Moq framework in C#.
Today, I got this weird error on my SQL script in Visual Studio 2017, where in it was highlighting various SQL statements when I copied the SQL file and added it to the project. Below is the exact error in Visual Studio 2017.
Error SQL70001: This statement is not recognized in this context.
However, the solution is simple. Select the file in the solution explorer, click F4 and change the Build option in properties window to none instead of build.
Let me give you a brief about what Office Web App Server is for those who don’t know what it is used for. Its basically a server which provides the Office Services to edit or view the office documents in the browser itself without the need of office installed on local machine of end users.
Installing OWA Server on Windows Server is not a pain until its Windows Server 2012 R2. Normally one would think like SharePoint it would give the list of pre-requisites which would be installed automatically but it doesn’t do that.
- Using ScriptManager Class.
- Using Page.RegisterClientScriptBlock or Page.RegisterStartupScript or Page.ClientScript object
Page.RegisterClientScriptBlock or Page.RegisterStartupScript methods are deprecated methods and they shouldn’t be used. Microsoft has replaced them with Page.ClientScript object methods.
ScriptManager class can also be used to do the same but with the slight difference, these methods are compatible with Asp.Net AJAX partial post backs where as the Page.ClientScript object methods are not compatible with Asp.Net AJAX.