Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 8 years ago.
Improve this question
I have a URL, such as http://www.mydomain.com/?param1=asd2¶m2=asd2.
I'd like to create a sort of Frequest object, so than I can easily do somethings like:
Request.Querystring("param1")
without do a further Split and access to the array. Can I?
Your question is not clear. Are you looking something like this?
var uri = new Uri("http://www.mydomain.com/?param1=asd2¶m2=asd2");
var nv = uri.ParseQueryString();
Console.WriteLine(nv["param1"]);
EDIT
It seams one of my referenced libraries implemented this extension Method. Anyway, it can be done as
var uri = new Uri("http://www.mydomain.com/?param1=asd2¶m2=asd2");
var nv = HttpUtility.ParseQueryString(uri.Query);
Console.WriteLine(nv["param1"]);
Related
Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 8 months ago.
Improve this question
var data = #"{
""owner1"":""Name"",
}";
Need to add variable in the above object in c#
If your data is json string, you can modify it by JObject like this:
var jsonData = JObject.Parse(data);
jsonData["owner1"] = "owner1";
jsonData["owner2"] = "owner2";
Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 1 year ago.
Improve this question
I'm new to C#.
I have a method that returns an object with the List of objects inside.
0 {{DapperRow, RecordedFormID = 'id1'}} object {Dapper.SqlMapper.DapperRow}
1 {{DapperRow, RecordedFormID = 'id2'}} object {Dapper.SqlMapper.DapperRow}
How can I get those ids as strings?
Here is a screenshot
You can use System.Linq namespace and do this:
yourObject.Select(x => x.RecordedFormID);
Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 2 years ago.
Improve this question
Is it possible to add some data, such as 123, to the "intList" variable below?
IQueryable<int> intList = Enumerable.Empty<int>().AsQueryable();
Many thanks in advance.
I would suggest one of the following options:
Either (if intList already exists):
intList = intList.AsEnumerable().Append(123).AsQueryable();
Or if it doesn't:
var intList = new List<int>(1){123}.AsQueryable();
Note generally AsQueryable is not commonly useful - but in contexts like unit tests (which seems to be your scenario here), code like above is acceptable.
Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 6 years ago.
Improve this question
I though it was simple. but I didn't manage to make this line of code add "\Game_Progress.xml" to my String
code_file.Insert(code_file.Length, "\\Game_Progress.xml");
You can append the string using the += operator:
code_file += "\\Game_Progress.xml";
Note: If you want to combine a path, you should consider using the Path Combine method:
System.IO.Path.Combine(code_file, "\\Game_Progress.xml")
C# can require an #prior to the string when using backslashes. Try:
code_file.Insert(code_file.Length, #"\\Game_Progress.xml");
Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 9 years ago.
Improve this question
I have a lot of txt files in Resources folder. One of them is corner.txt. I can access this file via this code snippet:
Properties.Resources.corner
I keep file names in string variables. For example:
string fileName = "corner.txt";
I want to access this file via:
Properties.Resources.fileName
Is this possible? How can I access?
I solved the problem this code snippet:
string st = Properties.Resources.ResourceManager.GetString(tableName);
So, I don't use the filename, I use the txt file's string. This is useful for me.
Thanks a lot.
You can use Reflection like that:
var type = typeof(Properties.Resources);
var property = type.GetProperty(fileName, BindingFlags.Static| BindingFlags.NonPublic|BindingFlags.Public);
var value = property.GetValue(null, null);
or use the ResourceManager like that:
value = Properties.Resources.ResourceManager.GetObject(fileName, Properties.Resources.Culture);