c#-3.0

regex pattern for a range and above 127

杀马特。学长 韩版系。学妹 提交于 2020-01-03 15:59:12
问题 I need a regex such that it matches following plus anything ascii above 127 (i.e 7F hex and above). Below works fine for the given range. string pattern = "[\x00-\x1F]"; 回答1: Try the or operator | (pipe) string pattern = "[\x00-\x1f]|[\x7f-\uffff]"; FF hex would be the max ASCII value. Here's a cheat sheet for further reference: http://www.mikesdotnetting.com/Article/46/CSharp-Regular-Expressions-Cheat-Sheet 回答2: Either: Accept characters in both ranges (with an alternation, [a-b]|[x-z] ), or

Why do unrelated (autopostback) methods get called when an Asp.Net ListBox autopostback method is invoked?

那年仲夏 提交于 2020-01-03 11:32:36
问题 I'm sure this is simple but it's driving me nuts. I have a ListBox on my page to show artists, which calls a method when the index is changed, and a button which loads an artist from that list in another page when clicked: <asp:ListBox ID="lbArtists" runat="server" Rows="1" AutoPostBack="true" OnSelectedIndexChanged="ShowArtistsWorks" /> <asp:Button ID="btnEditArtist" runat="server" Text="Edit the artist" OnClick="LoadArtist" /> Further on, I have a similar list of links, which also has an

Get key from value - Dictionary<string, List<string>>

生来就可爱ヽ(ⅴ<●) 提交于 2020-01-03 07:26:04
问题 I am having trouble getting the key by specifying a value. What is the best way I can achieve this? var st1= new List<string> { "NY", "CT", "ME" }; var st2= new List<string> { "KY", "TN", "SC" }; var st3= new List<string> { "TX", "OK", "MO" }; var statesToEmailDictionary = new Dictionary<string, List<string>>(); statesToEmailDictionary.Add("test1@gmail.com", st1); statesToEmailDictionary.Add("test2@gmail.com", st2); statesToEmailDictionary.Add("test3@gmail.com", st3); var emailAdd =

Question regarding threading/background workers

 ̄綄美尐妖づ 提交于 2020-01-03 04:19:27
问题 I have a question around threading and background workers that I hope you can help with. I plan on making an ftp application to upload a file to 50 servers. Rather than the user having to wait for each upload to finish before the next one starts I was looking at threading/background workers. Once an upload finishes I want to report the status of the upload "completed/failed" back to the UI. From my understanding, I will need to use background workers for this so I know when the task has

Connection string in app.config in a class library

血红的双手。 提交于 2020-01-01 09:32:46
问题 I am creating solution and inside I have three projects: A WCF Service Library Project A DataAccess Project (Class Library) A Web site for hosting WCF service The implementation of the service is on the project # 1, but in order to access the DataBase I use a second project that implements the data access using a class library project. That problem is in order to get data access I need to configure a connection string, but that connection string must be configurable in a production

Why am I getting a serialization error?

左心房为你撑大大i 提交于 2020-01-01 08:46:07
问题 I have the following code: class Program { static void Main(string[] args) { string xml = @"<ArrayOfUserSetting> <UserSetting> <Value>Proposals</Value> <Name>LastGroup</Name> </UserSetting> <UserSetting> <Value>Visible</Value> <Name>WidgetsVisibility</Name> </UserSetting> </ArrayOfUserSetting>"; List<UserSetting> settings = GetObjFromXmlDocument<List<UserSetting>>(xml); } public static T GetObjFromXmlDocument<T>(string xml) { T customType; XmlSerializer serializer = new XmlSerializer(typeof(T

Why am I getting a serialization error?

别等时光非礼了梦想. 提交于 2020-01-01 08:45:58
问题 I have the following code: class Program { static void Main(string[] args) { string xml = @"<ArrayOfUserSetting> <UserSetting> <Value>Proposals</Value> <Name>LastGroup</Name> </UserSetting> <UserSetting> <Value>Visible</Value> <Name>WidgetsVisibility</Name> </UserSetting> </ArrayOfUserSetting>"; List<UserSetting> settings = GetObjFromXmlDocument<List<UserSetting>>(xml); } public static T GetObjFromXmlDocument<T>(string xml) { T customType; XmlSerializer serializer = new XmlSerializer(typeof(T

How to set background color based on bool property in WPF

烂漫一生 提交于 2020-01-01 07:30:05
问题 I want to set the backgroun color for a GridViewColumn that is databound inside of a listview in WPF. I'm not sure how to ask this question being fairly new to WPF, otherwise I wouldn't have bothered all of you. I want to change the background color of the whole row, based on a bool flag in my databound object. In this case, I have, well, a "CaseDetail" object, that when there are internal notes "IsInternalNote" I want the color of the row to change. How can I pull this off in WPF? What I

convert XmlNode to XNode?

 ̄綄美尐妖づ 提交于 2020-01-01 04:38:05
问题 Anyone know off the top of their heads how to convert a System.Xml.XmlNode to System.Xml.Linq.XNode? 回答1: I've never tried, but my first thought would be something like: XmlNode myNode; XNode translatedNode = XDocument.Parse(myNode.OuterXml); 回答2: Eric White's blog is the place to be for cool XML/XLINQ conversions and such. I know this question pre-date's the post but I found it while looking at some other Q, so maybe people still come across this a fair amount. His blog has plenty of

How to display “Message box” using MVC3 controller

时光总嘲笑我的痴心妄想 提交于 2019-12-31 04:15:13
问题 I have been facing an issue to display "Message Box" after executing of some code in controller for ex:- public ActionResult IsLoginExsit(CustomerDO loginData) { JsonResult jsonResult = new JsonResult(); if (!string.IsNullOrEmpty(loginData.UserName) && !string.IsNullOrEmpty(loginData.Password)) { bool result = Businesss.Factory.BusinessFactory.GetRegistrations().IsLoginExist(loginData.UserName, loginData.Password); jsonResult.Data = result; } return jsonResult; } as seen in above example, if