Kod Kütüphanem ama elime ne gelirse burada dursun diye…

public List in viewstate

Do?ru Yaz?m:

public List<int> ImageString {
get {
    if (this.ViewState["ImageString"] == null) {
        this.ViewState["ImageString"] = new List<int>();
    }
    return (List<int>)(this.ViewState["ImageString"]);
}
 set { this.ViewState["ImageString"] = value; } 
}

Yanl?? Yaz?m:

public List<int> ImageString {
    get {
        if (this.ViewState["ImageString"] != null) {
            return (List<int>)(this.ViewState["ImageString"]);
        }
        return new List<int>();
    }
    set { this.ViewState["ImageString"] = value; }
}

Bu listeye herhangi bir ekleme olmas? için ViewState’in önceden var olmas? gerekir. E?er Bo??a olu?turulmas? gerekiyor. Daha sonra listeye istenen int de?erleri eklenebilir.

Kaynak : Stackoverflow

Related articles

Tuple?

A tuple is a data structure that has a specific number and sequence of elements. A tuple allows you to combine multiple values of possibly different types into a single object without having to create a custom class. This can be useful if you want to write a method that for example returns three related […]

Learn More

İki List<> Karşılaştırılması

var difList = list1.Where(a => !list2.Any(a1 => a1.id == a.id)) .Union(list2.Where(a => !list1.Any(a1 => a1.id == a.id)));   Kaynak : StackOverFlow

Learn More

C# – String format for Double

using System; public class Program { public static void Main(string[] args) { // Pattern 1: just two decimal places Console.WriteLine(“**************************************”); Console.WriteLine(“Pattern 1: just two decimal places”); Console.WriteLine(“**************************************”); Console.WriteLine(String.Format(“{0:0.00}”, 123.4567)); // “123.46” Console.WriteLine(String.Format(“{0:0.00}”, 123.4)); // “123.40” Console.WriteLine(String.Format(“{0:0.00}”, 123.0)); // “123.00” //Pattern 2: max. two decimal places Console.WriteLine(“**************************************”); Console.WriteLine(“Pattern 2: max. two decimal places”); Console.WriteLine(“**************************************”); Console.WriteLine(String.Format(“{0:0.##}”, 123.4567)); […]

Learn More

Bir yanıt yazın

E-posta adresiniz yayınlanmayacak. Gerekli alanlar * ile işaretlenmişlerdir