Regarding the addition of the List class, what should I do if I use the program below?
Please let me know.
using Amazon.S3.Model;
Filter filter = new Filter();
filter.S3KeyFilter.FilterRules.Add(newFilterRule("hoge", "1"));
Error Contents
NullReferenceException:Object reference not set to an instance of an object
You must create an instance of a S3KeyFilter
or FilterRules
class.
https://dotnetfiddle.net/5qxU0n
using Amazon.S3.Model;
using System.Collections.General;
using System;
usingServiceStack.Text;
public class program
{
public static void Main()
{
Filter filter = new Filter {
S3KeyFilter = new S3KeyFilter {
FilterRules = new List <FilterRule > {
new FilterRule("hoge", "1")
}
}
};
filter.S3KeyFilter.FilterRules.Add(newFilterRule("fuga", "2"));
Console.WriteLine(filter.S3KeyFilter.FilterRules.Dump());
}
}
© 2024 OneMinuteCode. All rights reserved.