Browsing 7239 questions and answers with Jon Skeet

Day/Month/Year doesn't display without hours

string date = Convert.ToString(context.SP_GetDate().FirstOrDefault().UpdateTime); UpdateTime is Day/Month/Year in my database however, When i use above query , update time...
Jon Skeet
people
quotationmark

Specify a format string when performing the conversion. Don't Convert.ToString, which doesn't allow for different format strings - call ToString on the DateTime. For example: DateTime updated =... more 1/7/2014 12:37:53 PM

people

Calling Https Url

I have written web service and hosted project on server with SSL certificate.If I want to call HTTPS url, I need to import certificate in JVM manually or through program on client...
Jon Skeet
people
quotationmark

Ideally, you should pay for a real SSL certificate (trusted by one of the common root certificate authorities), rather than getting a self-signed one. Then there won't be any need to important any certificates. The point about losing... more 1/7/2014 12:08:24 PM

people

Async Await Infinite Regression

You can only await an async method. However that async method itself needs to have an await statement inside it itself. Doesn't this lead to an infinite regression?
Jon Skeet
people
quotationmark

You can only await an async method. That's not true. You can await anything that follows the "awaitable pattern" (something with a GetAwaiter() method, the return type of which has appropriate IsCompleted, GetResult(), and... more 1/7/2014 5:11:14 AM

people

Wrong time format ios

I have a time picker which displays time in 12 Hour format. Internally i am converting it to 24 Hour format. The problem is, if the time taken is 10:24, it displays 10:01. i.e...
Jon Skeet
people
quotationmark

MM is "month of year", not "minute". You also want "s" (for seconds) rather than "S" (for fractions of a second). I suspect you want a format of HH:mm:ss. See the "date formatters" documentation for more inforamtion - in particular, UTS... more 1/7/2014 5:07:40 AM

people

Initialize Dictionary<string,string> from List<string>

Easiest way to do this, perhaps from an extension method? : var MyDic = new Dictionary<string,string>{ "key1", "val1", "key2", "val2", ...}; Where the dictionary winds...
Jon Skeet
people
quotationmark

The alternation is a bit of a pain. Personally I'd just do it longhand: var dictionary = new Dictionary<string, string>(); for (int index = 0; index < list.Count; index += 2) { dictionary[list[index]] = list[index +... more 1/7/2014 2:41:37 AM

people

What is the use of decorator sequences in deferred execution?

I am learning about LINQ, and trying to understand, how deferred execution works? The single line that is bothering me is :- Query operators provide deferred execution...
Jon Skeet
people
quotationmark

I won't answer for the actual terminology used, but the guts to understand is that LINQ to Objects is effectively implemented using iterator blocks (whether or not that's the actual implementation is somewhat irrelevant). So for example,... more 1/7/2014 2:02:31 AM

people

A Linq to replace unwanted characters

I have a Linq code to get acceptable characters and remove others. But this code replace others with ""(nothing + null+ string.empty etc) I would like to replace with space ( )....
Jon Skeet
people
quotationmark

Well you could use: // Alternatively use a HashSet<char> string acceptableCharacters = " 1234..."; string clean = new string(incomingText.Select(c => acceptableCharacters.Contains(c) ? ... more 1/7/2014 1:52:27 AM

people

Delegate System.Func<dbPSRModel.tbProject,int,bool> does not take 1 arguments

I'm trying to populate a modal using AJAX. This is the method that returns the data I hope to populate the modal with but I get a red line under (x => x.tbProject == i) and it...
Jon Skeet
people
quotationmark

Hmm. It's not the error message I'd have expected, but I suspect the problem may be related to the fact that you're referring to i within the lambda expression - and that's a variable which doesn't exist. That may be causing the compiler... more 1/7/2014 1:46:48 AM

people

Get data from column by using column name?

I iterate a DataTable's rows using - DataTable dt = getDataTableFromSomeWhere(); DataRow row = null; //for loop row = dt.Rows[i]; How do I get the value of a column of the...
Jon Skeet
people
quotationmark

Just use the indexer taking a string parameter: object value = row["ColumnName"]; EDIT: Assuming the value has been fetched in an appropriate type, I'd normally just cast to the CLR type you want: int someIntegerValue = (int)... more 1/7/2014 1:27:22 AM

people

AsyncBridge.Net35.0.2.0, await task

I'm using the asyncbridge for 3.5, and have run into a problem. When I have a method returning a void, I know I have to return a Task. However, the method below doesn't...
Jon Skeet
people
quotationmark

I suspect you can just change it to: public Task PingAsync() { return Task.Factory.FromAsync(client.BeginPing, client.EndPing, new object()); } There's no benefit in making this an async method - you're just trying to create a task... more 1/6/2014 9:09:07 AM

people