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
svitch
test1
Jhjj
convert a string of numbers to a list then use a forEach to loop through the list
dice roll
memes
saetr
Computing Time Zone Different
ReRoute Emails
Hehd