How fair is this?
-
bool?
is a nullable value type[^]. Null conditional operators[^] are something completely different. :)
"These people looked deep within my soul and assigned me a number based on the order in which I joined." - Homer
You just made it double productive :-D :thumbsup: thanks I was just thinking how can I google that. Then just went by searching ? operator in C#
Starting to think people post kid pics in their profiles because that was the last time they were cute - Jeremy Falcon.
-
If someone stores 'Sex' attrib as
bool isMale;
haha just seen this in code. :-D
Starting to think people post kid pics in their profiles because that was the last time they were cute - Jeremy Falcon.
Given genders are hard to keep up with these days I use google's api to retrieve an up-to-date list rather than storing my own
public class Gender
{
public string Key { get; set; }
public string Description { get; set; }
public string PronounSubset { get; set; }
}HttpWebRequest request = (HttpWebRequest)WebRequest.Create("https://genders.googleapis.com/genders/api/json?key=API\_KEY");
request.Method = "GET";
request.ContentType = "application/json";
WebResponse response = request.GetResponse();
using (var reader = new StreamReader(response.GetResponseStream()))
{
string data = reader.ReadToEnd();JavaScriptSerializer s = new JavaScriptSerializer(); var genders = s.Deserialize\>(data); foreach(var gender in genders) { System.Diagnostics.Debug.WriteLine("{0} {1} ({2})", gender.Key, gender.Description, gender.PronounSubset); }
}
-
Given genders are hard to keep up with these days I use google's api to retrieve an up-to-date list rather than storing my own
public class Gender
{
public string Key { get; set; }
public string Description { get; set; }
public string PronounSubset { get; set; }
}HttpWebRequest request = (HttpWebRequest)WebRequest.Create("https://genders.googleapis.com/genders/api/json?key=API\_KEY");
request.Method = "GET";
request.ContentType = "application/json";
WebResponse response = request.GetResponse();
using (var reader = new StreamReader(response.GetResponseStream()))
{
string data = reader.ReadToEnd();JavaScriptSerializer s = new JavaScriptSerializer(); var genders = s.Deserialize\>(data); foreach(var gender in genders) { System.Diagnostics.Debug.WriteLine("{0} {1} ({2})", gender.Key, gender.Description, gender.PronounSubset); }
}
:omg: :wtf: It won't help; you're bound to offend someone, anyway...
Freedom is the freedom to say that two plus two make four. If that is granted, all else follows. -- 6079 Smith W.
-
Given genders are hard to keep up with these days I use google's api to retrieve an up-to-date list rather than storing my own
public class Gender
{
public string Key { get; set; }
public string Description { get; set; }
public string PronounSubset { get; set; }
}HttpWebRequest request = (HttpWebRequest)WebRequest.Create("https://genders.googleapis.com/genders/api/json?key=API\_KEY");
request.Method = "GET";
request.ContentType = "application/json";
WebResponse response = request.GetResponse();
using (var reader = new StreamReader(response.GetResponseStream()))
{
string data = reader.ReadToEnd();JavaScriptSerializer s = new JavaScriptSerializer(); var genders = s.Deserialize\>(data); foreach(var gender in genders) { System.Diagnostics.Debug.WriteLine("{0} {1} ({2})", gender.Key, gender.Description, gender.PronounSubset); }
}
-
Given genders are hard to keep up with these days I use google's api to retrieve an up-to-date list rather than storing my own
public class Gender
{
public string Key { get; set; }
public string Description { get; set; }
public string PronounSubset { get; set; }
}HttpWebRequest request = (HttpWebRequest)WebRequest.Create("https://genders.googleapis.com/genders/api/json?key=API\_KEY");
request.Method = "GET";
request.ContentType = "application/json";
WebResponse response = request.GetResponse();
using (var reader = new StreamReader(response.GetResponseStream()))
{
string data = reader.ReadToEnd();JavaScriptSerializer s = new JavaScriptSerializer(); var genders = s.Deserialize\>(data); foreach(var gender in genders) { System.Diagnostics.Debug.WriteLine("{0} {1} ({2})", gender.Key, gender.Description, gender.PronounSubset); }
}
-
Given genders are hard to keep up with these days I use google's api to retrieve an up-to-date list rather than storing my own
public class Gender
{
public string Key { get; set; }
public string Description { get; set; }
public string PronounSubset { get; set; }
}HttpWebRequest request = (HttpWebRequest)WebRequest.Create("https://genders.googleapis.com/genders/api/json?key=API\_KEY");
request.Method = "GET";
request.ContentType = "application/json";
WebResponse response = request.GetResponse();
using (var reader = new StreamReader(response.GetResponseStream()))
{
string data = reader.ReadToEnd();JavaScriptSerializer s = new JavaScriptSerializer(); var genders = s.Deserialize\>(data); foreach(var gender in genders) { System.Diagnostics.Debug.WriteLine("{0} {1} ({2})", gender.Key, gender.Description, gender.PronounSubset); }
}
I thought, "This looks handy. Let me try it." I have my own API_KEY so I set up in the call but couldn't make it work to genders.googleapis.com - I got a 404 error. Any ideas?
- I would love to change the world, but they won’t give me the source code.
-
I just love it, when a fun post turns out to be a productive one. I'm just discovering this "null-conditional Operators" :laugh: I'm a bit outdated, may be C# 4.0, that's when I became a manager. lol happy to take away these cool tips :beer: Thanks Marc!
Starting to think people post kid pics in their profiles because that was the last time they were cute - Jeremy Falcon.
Vunic wrote:
Thanks Marc!
YW! Richard beat me to it, but my favorites are continuation and coalescing operators, so you can write stuff like this (not that you'd want to, mind you, at least without really thinking about whether your data model is really right, but really handy when you need it!):
int? n;
string ns = n?.ToString() ?? "0"; // oops, forgot the quotes in the original post.Latest Article - A Concise Overview of Threads Learning to code with python is like learning to swim with those little arm floaties. It gives you undeserved confidence and will eventually drown you. - DangerBunny Artificial intelligence is the only remedy for natural stupidity. - CDP1802
-
Vunic wrote:
Thanks Marc!
YW! Richard beat me to it, but my favorites are continuation and coalescing operators, so you can write stuff like this (not that you'd want to, mind you, at least without really thinking about whether your data model is really right, but really handy when you need it!):
int? n;
string ns = n?.ToString() ?? "0"; // oops, forgot the quotes in the original post.Latest Article - A Concise Overview of Threads Learning to code with python is like learning to swim with those little arm floaties. It gives you undeserved confidence and will eventually drown you. - DangerBunny Artificial intelligence is the only remedy for natural stupidity. - CDP1802
-
I thought, "This looks handy. Let me try it." I have my own API_KEY so I set up in the call but couldn't make it work to genders.googleapis.com - I got a 404 error. Any ideas?
- I would love to change the world, but they won’t give me the source code.
He was probably joking. The Android SDK defines it as female, male, or other. See [Person.Gender | Google APIs for Android | Google Developers](https://developers.google.com/android/reference/com/google/android/gms/plus/model/people/Person.Gender)
Nish Nishant Consultant Software Architect Ganymede Software Solutions LLC www.ganymedesoftwaresolutions.com
-
He was probably joking. The Android SDK defines it as female, male, or other. See [Person.Gender | Google APIs for Android | Google Developers](https://developers.google.com/android/reference/com/google/android/gms/plus/model/people/Person.Gender)
Nish Nishant Consultant Software Architect Ganymede Software Solutions LLC www.ganymedesoftwaresolutions.com