c# Programming Glossary: type
Deserialize JSON into C# dynamic object? http://stackoverflow.com/questions/3142495/deserialize-json-into-c-sharp-dynamic-object a way to deserialize JSON content into a C# 4 dynamic type It would be nice to skip creating a bunch of classes in order.. Deserialize IDictionary string object dictionary Type type JavaScriptSerializer serializer if dictionary null throw new.. null throw new ArgumentNullException dictionary return type typeof object new DynamicJsonObject dictionary null public override..
Dynamic LINQ OrderBy on IEnumerable<T> http://stackoverflow.com/questions/41244/dynamic-linq-orderby-on-ienumerablet string methodName string props property.Split '.' Type type typeof T ParameterExpression arg Expression.Parameter type x.. methodName string props property.Split '.' Type type typeof T ParameterExpression arg Expression.Parameter type x Expression.. type typeof T ParameterExpression arg Expression.Parameter type x Expression expr arg foreach string prop in props use reflection..
Casting vs using the 'as' keyword in the CLR http://stackoverflow.com/questions/496096/casting-vs-using-the-as-keyword-in-the-clr I've found is that I'm doing a lot of casting or object type conversion. What I'd like to know is if there is a difference.. it's worth using which. Don't do this Bad code checks type twice for no reason if randomObject is TargetType TargetType.. assumptions and the exception correctly shows the type of bug. This will throw an exception if randomObject is non..
What is the difference between Decimal, Float and Double in C#? http://stackoverflow.com/questions/618535/what-is-the-difference-between-decimal-float-and-double-in-c this question float and double are floating binary point types . In other words they represent a number like this 10001.10010110011.. within the value. decimal is a floating decimal point type . In other words they represent a number like this 12345.65789.. the value that's what makes decimal still a floating point type instead of a fixed point type. The important thing to note is..
Deep cloning objects in C# http://stackoverflow.com/questions/78536/deep-cloning-objects-in-c-sharp summary Perform a deep Copy of the object. summary typeparam name T The type of object being copied. typeparam param.. a deep Copy of the object. summary typeparam name T The type of object being copied. typeparam param name source The object.. summary typeparam name T The type of object being copied. typeparam param name source The object instance to copy. param returns..
Conditional operator cannot cast implicitly? http://stackoverflow.com/questions/2215745/conditional-operator-cannot-cast-implicitly expression without knowing what it is being assigned to. Type information flows out of an expression not into an expression...
How to use reflection to call generic Method? http://stackoverflow.com/questions/232535/how-to-use-reflection-to-call-generic-method way to invoke GenericMethod using the type stored in the myType variable public class Sample public void Example string typeName.. public class Sample public void Example string typeName Type myType FindType typeName what goes here to call GenericMethod.. class Sample public void Example string typeName Type myType FindType typeName what goes here to call GenericMethod T GenericMethod..
Why XML-Serializable class need a parameterless constructor http://stackoverflow.com/questions/267724/why-xml-serializable-class-need-a-parameterless-constructor obj XmlSerializer serializer new XmlSerializer obj.GetType using StringWriter writer new StringWriter serializer.Serialize.. a parameterless constructor. at System.Xml.Serialization.TypeDesc.CheckSupported at System.Xml.Serialization.TypeScope.GetTypeDesc.. at System.Xml.Serialization.TypeScope.GetTypeDesc Type type MemberInfo sourc e Boolean directReference..
Is there a better alternative than this to 'switch on type'? http://stackoverflow.com/questions/298976/is-there-a-better-alternative-than-this-to-switch-on-type this to 'switch on type' Seeing as C# can't switch on a Type which I gather wasn't added as a special case because is a relationships.. else throw new ArgumentException Unexpected type o.GetType c# switch statement system.type share improve this question.. I wrote a blog post awhile back detailing how to build a TypeSwitch structure. http blogs.msdn.com jaredpar archive 2008 05..
Deserialize JSON into C# dynamic object? http://stackoverflow.com/questions/3142495/deserialize-json-into-c-sharp-dynamic-object object Deserialize IDictionary string object dictionary Type type JavaScriptSerializer serializer if dictionary null throw.. new NotImplementedException public override IEnumerable Type SupportedTypes get return new ReadOnlyCollection Type new List.. public override IEnumerable Type SupportedTypes get return new ReadOnlyCollection Type new List Type new typeof..
Good or bad practice for Dialogs in wpf with MVVM? http://stackoverflow.com/questions/3801681/good-or-bad-practice-for-dialogs-in-wpf-with-mvvm in my resource file app.xaml or something DataTemplate DataType x Type DialogViewModel EditOrNewAuswahlItemVM DialogView EditOrNewAuswahlItem.. file app.xaml or something DataTemplate DataType x Type DialogViewModel EditOrNewAuswahlItemVM DialogView EditOrNewAuswahlItem..
Dynamic LINQ OrderBy on IEnumerable<T> http://stackoverflow.com/questions/41244/dynamic-linq-orderby-on-ienumerablet property string methodName string props property.Split '.' Type type typeof T ParameterExpression arg Expression.Parameter type.. prop expr Expression.Property expr pi type pi.PropertyType Type delegateType typeof Func .MakeGenericType typeof T type.. expr Expression.Property expr pi type pi.PropertyType Type delegateType typeof Func .MakeGenericType typeof T type LambdaExpression..
C# String enums http://stackoverflow.com/questions/424366/c-sharp-string-enums string GetStringValue Enum value string output null Type type value.GetType Check first in our cached results... Look.. Enum value string output null Type type value.GetType Check first in our cached results... Look for our 'StringValueAttribute'..
How to get the type of T from a generic List<T> http://stackoverflow.com/questions/557340/how-to-get-the-type-of-t-from-a-generic-listt T ... . Later when I initialize the class the T becomes MyTypeObject1 . So I have a generic list List MyTypeObject1 . I would.. T becomes MyTypeObject1 . So I have a generic list List MyTypeObject1 . I would like to know what type of object the list of.. abc contain what type of object I cannot do abc 0 .GetType because the list might contain zero elements. How can I do it..
Developing Internet Explorer Extensions? http://stackoverflow.com/questions/5643819/developing-internet-explorer-extensions MSIL SpecificVersion False SpecificVersion EmbedInteropTypes True EmbedInteropTypes HintPath C Program Files x86 Microsoft.. False SpecificVersion EmbedInteropTypes True EmbedInteropTypes HintPath C Program Files x86 Microsoft Visual Studio 9.0 Common7.. neutral PublicKeyToken b03f5f7f11d50a3a EmbedInteropTypes True EmbedInteropTypes Reference Reference Include System Reference..
Retrieving Property name from lambda expression http://stackoverflow.com/questions/671968/retrieving-property-name-from-lambda-expression method MemberExpression memberExpr null if lambda.Body.NodeType ExpressionType.Convert memberExpr UnaryExpression lambda.Body.. memberExpr null if lambda.Body.NodeType ExpressionType.Convert memberExpr UnaryExpression lambda.Body .Operand as.. .Operand as MemberExpression else if lambda.Body.NodeType ExpressionType.MemberAccess memberExpr lambda.Body as MemberExpression..
Create Generic method constraining T to an Enum http://stackoverflow.com/questions/79126/create-generic-method-constraining-t-to-an-enum generics enums share improve this question Since Enum Type implements IConvertible interface a better implementation should..
Nullable types and the ternary operator: why is `? 10 : null` forbidden? [duplicate] http://stackoverflow.com/questions/858080/nullable-types-and-the-ternary-operator-why-is-10-null-forbidden the nullable int. However the compiler complains Error 1 Type of conditional expression cannot be determined because there..
Should you make multiple insert calls or pass XML? http://stackoverflow.com/questions/10295326/should-you-make-multiple-insert-calls-or-pass-xml type of table with all fields which needs to insert CREATE TYPE TargetUDT1 AS TABLE FirstName varchar 100 NOT NULL LastName..
Insert entire DataTable into database at once instead of row by row? http://stackoverflow.com/questions/10405373/insert-entire-datatable-into-database-at-once-instead-of-row-by-row in your database create the following two objects CREATE TYPE dbo.MyDataTable you can be more speciifc here AS TABLE col1..
How to pass an array into a SQL Server stored procedure http://stackoverflow.com/questions/11102358/how-to-pass-an-array-into-a-sql-server-stored-procedure in your database create the following two objects CREATE TYPE dbo.EmployeeList AS TABLE EmployeeID INT GO CREATE PROCEDURE..
Determine if DataColumn is numeric http://stackoverflow.com/questions/1725903/determine-if-datacolumn-is-numeric an extension method for the DataColumn type not for the TYPE . I hate the if...then..else thing so instead I use a SETS based..
How to check if file exists on FTP before FtpWebRequest http://stackoverflow.com/questions/347897/how-to-check-if-file-exists-on-ftp-before-ftpwebrequest most ftp servers but not all. Some servers require sending TYPE I before the SIZE command will work. One would have thought.. is either downloading or uploading a file it will NOT send TYPE I . See discussion and Microsoft response here . I'd recommend..
Comparison of XSD Code Generators http://stackoverflow.com/questions/386155/comparison-of-xsd-code-generators w with 1 Regex replace open documents case whole word w TYPE with 1 Replace open documents case whole word System.DateTime..
Short cut to create properties in Visual Studio? http://stackoverflow.com/questions/3871270/short-cut-to-create-properties-in-visual-studio press tab twice that will generate the following. public TYPE Type get set Then you change TYPE and Type public string myString.. the following. public TYPE Type get set Then you change TYPE and Type public string myString get set You can also get the..
OracleParameter and IN Clause http://stackoverflow.com/questions/541466/oracleparameter-and-in-clause with ODP.NET Create a TABLE type in your database CREATE TYPE t_varchar2 AS TABLE OF VARCHAR2 4000 Create a collection parameter..
problem using Oracle parameters in SELECT IN http://stackoverflow.com/questions/6155146/problem-using-oracle-parameters-in-select-in At first you create a table type e.g. for NUMBER CREATE TYPE number_table AS TABLE OF NUMBER When you create the parameter..
C# SQL Server - Passing a list to a stored procedure http://stackoverflow.com/questions/7097079/c-sharp-sql-server-passing-a-list-to-a-stored-procedure how to use it Create your User Defined Table Type CREATE TYPE dbo . StringList AS TABLE Item NVARCHAR MAX NULL Next you need..
How to update textbox in form1 from form2? http://stackoverflow.com/questions/7969582/how-to-update-textbox-in-form1-from-form2 put code into Form1 next... specifically typecasting the TYPE of form being passed in not just a generic form. We need to..
Entity Framework Stored Procedure Table Value Parameter http://stackoverflow.com/questions/8157345/entity-framework-stored-procedure-table-value-parameter the User Defined Table looks like the following... CREATE TYPE dbo . udt_Warnings AS TABLE WarningCode nvarchar 5 NULL StatusID..
How to insert a data table into SQL Server database table? http://stackoverflow.com/questions/9075159/how-to-insert-a-data-table-into-sql-server-database-table Create a User Defined TableType in your database CREATE TYPE dbo . MyTableType AS TABLE Id int NOT NULL Name nvarchar 128..
Is it possible to use a MySql User Defined Variable in a .NET MySqlCommand? http://stackoverflow.com/questions/958953/is-it-possible-to-use-a-mysql-user-defined-variable-in-a-net-mysqlcommand 1 rownum t . FROM SELECT @rownum 0 r SELECT DISTINCT TYPE FROM `node` WHERE TYPE NOT IN 'ad' 'chatroom' t It is using.. SELECT @rownum 0 r SELECT DISTINCT TYPE FROM `node` WHERE TYPE NOT IN 'ad' 'chatroom' t It is using the @rownum to number each..
using various types in a using statement (C#) http://stackoverflow.com/questions/966086/using-various-types-in-a-using-statement-c it accept multiple objects ONLY IF THEY ARE OF THE SAME TYPE I don't get it since all they need to be is IDisposable. If..
|