gpt4 book ai didi

c# - WP8 KnownContactProperties.Birthdate 无法设置值

转载 作者:行者123 更新时间:2023-12-02 22:16:27 24 4
gpt4 key购买 nike

var store = await ContactStore.CreateOrOpenAsync();
StoredContact sc = new StoredContact(store);
IDictionary<string, object> values = await sc.GetPropertiesAsync();
values[KnownContactProperties.FamilyName] = "bbb";
values[KnownContactProperties.GivenName]= "worerrrrld";

//*************problem here**************
Nullable<DateTime> birth = DateTime.Now;
values[KnownContactProperties.Birthdate] = birth;
//values[KnownContactProperties.Birthdate] = DateTime.Now;
//values[KnownContactProperties.Birthdate] = "2010-05-10";
//it will cause exception by any way above.
//***************************************

await sc.SaveAsync();//Exception throw here :System.InvalidCastException

关于windows phone8 API

Windows.Phone.PersonalInformation 命名空间

StoredContact类太奇怪了!

任何人都可以帮助我!如何设置此 KnownContactProperties.Birthdate

最佳答案

InvalidCastException 是正常的,因为预期的对象是 DateTimeOffset。

试试这个:

values[KnownContactProperties.Birthdate] = new DateTimeOffset(DateTime.Parse("2010-05-10"));

问候。

关于c# - WP8 KnownContactProperties.Birthdate 无法设置值,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/14376342/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com