c#-4.0

How to convert sting to datetime format like MM/dd/yyyy

爷,独闯天下 提交于 2020-01-20 08:58:05
问题 i get the string value like 01/05/2012(MM/dd/yyyy) , now i have to convert into datetime string s="01/05/2012"; datetime dt=convert.todatetime(s); Now dt value is 1/5/2012, but i have to get dt value 01/05/2012, how to get the value , plese give me any idea about that. Thanks hemanth 回答1: You are creating your DateTime object correctly, you are just looking at the internal representaion of the DateTime. The way that it is output depends on the Format String you give its ToString Method. i.e.:

Remove specific properties from JSON object

落爺英雄遲暮 提交于 2020-01-19 13:10:27
问题 I have a JSON: { "scbs_currentstatus": "", "scbs_primaryissue": "", "_umb_id": "Test", "_umb_creator": "Admin", "_umb_createdate": "0001-01-01 00:00:00", "_umb_updatedate": "0001-01-01 00:00:00", "_umb_doctype": "Test", "_umb_login": "Test", "_umb_email": "Test", "_umb_password": { "newPassword": "Test", "oldPassword": null, "reset": null, "answer": null }, "_umb_membergroup": { " User": false, "Line User": true, "Callback User": false, "Su User": false, }, "umbracoMemberComments": "Test",

Remove specific properties from JSON object

女生的网名这么多〃 提交于 2020-01-19 13:10:08
问题 I have a JSON: { "scbs_currentstatus": "", "scbs_primaryissue": "", "_umb_id": "Test", "_umb_creator": "Admin", "_umb_createdate": "0001-01-01 00:00:00", "_umb_updatedate": "0001-01-01 00:00:00", "_umb_doctype": "Test", "_umb_login": "Test", "_umb_email": "Test", "_umb_password": { "newPassword": "Test", "oldPassword": null, "reset": null, "answer": null }, "_umb_membergroup": { " User": false, "Line User": true, "Callback User": false, "Su User": false, }, "umbracoMemberComments": "Test",

does Request.Querystring automatically url decode a string?

↘锁芯ラ 提交于 2020-01-19 05:37:05
问题 I'm working with a page where I have a url like: /directory/company/manufacturer Using some re-write rules this gets re-written testing with /directory/company/dunkin%26donuts/ Some manufacturers have an ampersand in their name. So I thought I could just replace the ampersand with %26 . However, when I debug the code and hover over Request.QueryString it shows me {qq=company&manf=dunkin&donuts&cond=} and Request.QueryString["manf"] gives me 'dunkin' If I use %24 ($) instead of ampersand,

Run PowerShell-Script from C# Application

假如想象 提交于 2020-01-19 05:07:08
问题 I'm trying to execute a PowerShell script from a c# application. The script has to be executed under a special usercontext. I've tried different scenarios some are working some not: 1. direct call from PowerShell I've called the script directly from a ps-console which is running under the correct usercredentials. C:\Scripts\GroupNewGroup.ps1 1 Result: Successfully running the script. 2. from a c# console application I've called the script from a c# consoleapplication which is started under

How to encode the plus (+) symbol in URL

◇◆丶佛笑我妖孽 提交于 2020-01-19 03:10:51
问题 The URL link below will open a new Google mail window. The problem I have is that Google replaces all the plus (+) sign in the email body with blank space. It looks like it only happens with the + sign. Any suggestions on how to remedy this? ( I am working the ASP.NET web page) https://mail.google.com/mail?view=cm&tf=0&to=someemail@somedomain.com&su=some subject&body=Hi there+Hello there (In the body email, "Hi there+Hello there" will show up as "Hi there Hello there") 回答1: The + character

How to encode the plus (+) symbol in URL

对着背影说爱祢 提交于 2020-01-19 03:09:19
问题 The URL link below will open a new Google mail window. The problem I have is that Google replaces all the plus (+) sign in the email body with blank space. It looks like it only happens with the + sign. Any suggestions on how to remedy this? ( I am working the ASP.NET web page) https://mail.google.com/mail?view=cm&tf=0&to=someemail@somedomain.com&su=some subject&body=Hi there+Hello there (In the body email, "Hi there+Hello there" will show up as "Hi there Hello there") 回答1: The + character

SimpleIoc - can it provide new instance each time required?

半腔热情 提交于 2020-01-19 01:31:46
问题 So far as I understand, SimpleIoc uses GetInstance method to retrieve an instance of a class that is registered. If the instance doesnt exist, it will create it. However, this instance is cached and always retrieved, which mimics the singleton pattern. My thinking is that there is no need to keep an instance of ViewModel in a memory if there is a small possibility that this ViewModel will be needed twice, so I would like to create new instance of it each time that is needed. If we have are

Create generic abstract class using EF database first approach

会有一股神秘感。 提交于 2020-01-17 07:15:10
问题 I have some similar entities and I want to create a generic abstract class for CRUD operations for them, but I don't know how can access to entities in generic class. For example: public abstract class HeaderRepository<T> { public HeaderRepository() { } public virtual byte[] Insert(T item) { using (MyEntities context = new MyEntities()) { context.***** <-- What I should write to add an object to entity T } } } I hope I've got it. 回答1: You need to set your DB set. It would be better to have a

Convert Int to String while serialize object using JSON.NET

江枫思渺然 提交于 2020-01-17 05:30:10
问题 I tried to convert DataTable to JSON string using JObject (NewtonSoft.dll). In my case table may have values with different data types. I want to convert those values to string while serialize the object. DataTable tab = new DataTable(); tab.Columns.Add("ID", typeof(int)); tab.Columns.Add("Name"); tab.Rows.Add(1, "Role1"); tab.Rows.Add(2, "Role2"); string strValues = JsonConvert.SerializeObject(tab); --output of strValues -- [{"ID":1,"Name":"Role1"},{"ID":2,"Name":"Role2"}] But it should be