Run Code
|
API
|
Code Wall
|
Misc
|
Feedback
|
Login
|
Theme
|
Privacy
|
Patreon
Invalid cast
//Rextester.Program.Main is the entry point for your code. Don't change it. //Compiler version 4.0.30319.17929 for Microsoft (R) .NET Framework 4.5 using System; using System.Collections.Generic; using System.Linq; using System.Text.RegularExpressions; namespace Rextester { public class Program { public static void Main(string[] args) { long longVariable = 6; int intVariable = ConvertToType<int>(longVariable); Console.WriteLine(intVariable); //Console.ReadKey(); } private static T ConvertToType<T>(object obj) { return (T)obj; } // This version would, however, work just fine private static T ConvertToType2<T>(object obj) where T : IConvertible { return (T) Convert.ChangeType(obj, typeof(T)); } } }
run
|
edit
|
history
|
help
0
vigenere cypher
19.05.2020
Jjjj
Dungeon Game
constructor execution sequence
megha
up casting down casting
test using C#2019
Simple Enum Parsing
Fórum ➡ Parallel Threads ( The Funniest Version ) ♦