I would like to rewrite the python code example from the book to C# equivalent in order to test its functionality.
The code is the following:
q = "select target_id from connection where source_id=me() and target_type='user'"
my_friends = [str(t['target_id']) for t in fql.query(q)]
q = "select uid1, uid2 from friends where uid1 in (%s) and iud2 in (%s)" %
(",".join(my_friends), ",".join(my_friends),)
mutual_friendships = fql(q)
What I don’t know is sign %s and what (%s) in code means. I would really appreciate if anyone could write the equivalent code in C#.
String formatting operation in Python
%sare replaced with the corresponding values from the tuple passed after%operator.How it works in Python
For example this:
would print this:
How to replace it with C#
You need to use
String.Format(), as mentioned eg. here: http://blog.stevex.net/string-formatting-in-csharp/It works the way that is very similar to Python’s string
format()method (available since Python 2.6).