I'm creating my own handler method and I want to know how to implement a Bundle parameter that is optional.
In Android it would look like
public bool updateUI(int mode, Bundle... params)
{
switch (mode)
{
case 0: return doStuff(params.getString("Name"));
default: break;
}
}
This is not covered in the migration guide .
How to use Named and Optional arguments in .NET Framework and in Windows Phone as well:
http://msdn.microsoft.com/en-us/library/dd264739.aspx
Or you can use the params keyword fore passing arbitrary number of arguments:
http://msdn.microsoft.com/en-us/library/w5zay9db(v=VS.100).aspx
Edit: not sure, how the Bundle actually works, but it looks like a generic container for data. You might try to use dynamic type and the ExpandoObject :
http://msdn.microsoft.com/en-us/library/system.dynamic.expandoobject(v=vs.95).aspx
dynamic d = new ExpandoObject();
d.Data = "data";
d.Result = 42;
return d.Data;
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.