Click here to Skip to main content
15,890,845 members
Home / Discussions / C#
   

C#

 
AnswerRe: how read file from Open with in C# Pin
Luc Pattyn30-Sep-21 8:30
sitebuilderLuc Pattyn30-Sep-21 8:30 
QuestionQuestion About Async Pin
Kevin Marois29-Sep-21 10:21
professionalKevin Marois29-Sep-21 10:21 
AnswerRe: Question About Async Pin
Pete O'Hanlon29-Sep-21 20:22
mvePete O'Hanlon29-Sep-21 20:22 
GeneralRe: Question About Async Pin
Kevin Marois30-Sep-21 4:24
professionalKevin Marois30-Sep-21 4:24 
GeneralRe: Question About Async Pin
Richard Deeming30-Sep-21 4:41
mveRichard Deeming30-Sep-21 4:41 
GeneralRe: Question About Async Pin
Kevin Marois30-Sep-21 4:48
professionalKevin Marois30-Sep-21 4:48 
GeneralRe: Question About Async Pin
Richard Deeming30-Sep-21 5:05
mveRichard Deeming30-Sep-21 5:05 
GeneralRe: Question About Async Pin
Kevin Marois30-Sep-21 5:20
professionalKevin Marois30-Sep-21 5:20 
AnswerRe: Question About Async Pin
Richard Deeming29-Sep-21 21:54
mveRichard Deeming29-Sep-21 21:54 
GeneralRe: Question About Async Pin
Kevin Marois30-Sep-21 4:23
professionalKevin Marois30-Sep-21 4:23 
QuestionMakeGenericType/CreateInstance Object to underlying Type at run-time: why this works is driving me crazy Pin
BillWoodruff28-Sep-21 5:45
professionalBillWoodruff28-Sep-21 5:45 
AnswerRe: MakeGenericType/CreateInstance Object to underlying Type at run-time: why this works is driving me crazy Pin
Richard Deeming28-Sep-21 6:20
mveRichard Deeming28-Sep-21 6:20 
GeneralRe: MakeGenericType/CreateInstance Object to underlying Type at run-time: why this works is driving me crazy Pin
BillWoodruff28-Sep-21 9:47
professionalBillWoodruff28-Sep-21 9:47 
AnswerRe: MakeGenericType/CreateInstance Object to underlying Type at run-time: why this works is driving me crazy Pin
OriginalGriff28-Sep-21 6:30
mveOriginalGriff28-Sep-21 6:30 
GeneralRe: MakeGenericType/CreateInstance Object to underlying Type at run-time: why this works is driving me crazy Pin
BillWoodruff28-Sep-21 10:19
professionalBillWoodruff28-Sep-21 10:19 
GeneralRe: MakeGenericType/CreateInstance Object to underlying Type at run-time: why this works is driving me crazy Pin
OriginalGriff28-Sep-21 10:40
mveOriginalGriff28-Sep-21 10:40 
GeneralRe: MakeGenericType/CreateInstance Object to underlying Type at run-time: why this works is driving me crazy Pin
BillWoodruff29-Sep-21 0:57
professionalBillWoodruff29-Sep-21 0:57 
Questionled matrix display Pin
Member 1537173026-Sep-21 7:49
Member 1537173026-Sep-21 7:49 
AnswerRe: led matrix display Pin
OriginalGriff26-Sep-21 8:33
mveOriginalGriff26-Sep-21 8:33 
QuestionC# 8 nullable reference question / conundrum Pin
Super Lloyd25-Sep-21 1:36
Super Lloyd25-Sep-21 1:36 
QuestionConvering time representation format Pin
Alex Dunlop21-Sep-21 23:26
Alex Dunlop21-Sep-21 23:26 
Hi,
I tried to convert time representation (for example from 8:22PM to 20:22:00). Itried this code in LinqPad and it worked but in VS it doen not work well.

C#
<pre>public static string TimeConverter(string time)
		{
			string formattedTime;
			string[] tSeperate = time.Split(':');
			string hour = tSeperate[0];
			string minut = string.Empty;
			List<char> number = tSeperate[1].Where(x => char.IsNumber(x)).Select(x => x).ToList();
			int n = number.Count();
			for (int i = 0; i < n; i++)
			{
				if (i + 1 < n)
				{
					minut = string.Format(@"{0}{1}", number[i], number[i + 1]);
				}
			}
			IEnumerable<char> stringQuery = time.Where(x => char.IsLetter(x)).Select(x => x);
			var myChar = stringQuery.First();
			if (myChar.ToString() == "P")
			{
				switch (hour)
				{
					case "1":
						hour = "13";
						break;
					case "2":
						hour = "14";
						break;
					case "3":
						hour = "15";
						break;
					case "4":
						hour = "16";
						break;
					case "5":
						hour = "17";
						break;
					case "6":
						hour = "18";
						break;
					case "7":
						hour = "19";
						break;
					case "8":
						hour = "20";
						break;
					case "9":
						hour = "21";
						break;
					case "10":
						hour = "22";
						break;
					case "11":
						hour = "23";
						break;
					case "12":
						hour = "00";
						break;
				}
				formattedTime = string.Format(@"{0}:{1}:00", hour, minut);
			}
			else
			{
				formattedTime = string.Format(@"{0}:{1}:00", hour, minut);
			}
			return formattedTime;
		}


The problem is that the following part cannot detect PM or AM in Visual Studio:

C#
<pre>IEnumerable<char> stringQuery = time.Where(x => char.IsLetter(x)).Select(x => x);


I want to use this code in a for loop to convert the time format of thousands of rows.
Please help me.
AnswerRe: Convering time representation format Pin
Peter_in_278022-Sep-21 1:28
professionalPeter_in_278022-Sep-21 1:28 
AnswerRe: Convering time representation format PinPopular
Richard Deeming22-Sep-21 1:37
mveRichard Deeming22-Sep-21 1:37 
AnswerRe: Convering time representation format Pin
BillWoodruff22-Sep-21 22:00
professionalBillWoodruff22-Sep-21 22:00 
AnswerRe: Convering time representation format Pin
Pete O'Hanlon23-Sep-21 2:03
mvePete O'Hanlon23-Sep-21 2:03 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.