Skip to content

Instantly share code, notes, and snippets.

@uzzu
Created August 16, 2013 03:43
Show Gist options
  • Select an option

  • Save uzzu/6247138 to your computer and use it in GitHub Desktop.

Select an option

Save uzzu/6247138 to your computer and use it in GitHub Desktop.
nullを許容しない型はnull許容型で取得しようね <http://msdn.microsoft.com/ja-jp/library/vstudio/2cf62fcy.aspx>
using NUnit.Framework;
using System.Collections.Generic;
[TestFixture]
public class DictionaryWithNullValueTest
{
[Test]
public void DictionaryCanGetNullableInteger()
{
Dictionary<string, object> dict = (Dictionary<string, object>) MiniJSON.Json.Deserialize("{ \"hoge\": null }");
Assert.True(dict.ContainsKey("hoge"));
int? hoge = (int?) dict["hoge"];
Assert.IsNull(hoge);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment