Search Results

Search found 35302 results on 1413 pages for 'string literals'.

Page 111/1413 | < Previous Page | 107 108 109 110 111 112 113 114 115 116 117 118  | Next Page >

  • how to pass an id number string to this class (asp.net, c#)

    - by Phil
    I'm very much a vb person, but have had to use this id number class in c#. I got it from http://www.codingsanity.com/idnumber.htm : using System; using System.Text.RegularExpressions; namespace Utilities.SouthAfrica { /// <summary> /// Represents a South African Identity Number. /// valid number = 7707215230080 /// invalid test number = 1234567891234 /// /// </summary> [Serializable()] public class IdentityNumber { #region Enumerations /// <summary> /// Indicates a gender. /// </summary> public enum PersonGender { Female = 0, Male = 5 } public enum PersonCitizenship { SouthAfrican = 0, Foreign = 1 } #endregion #region Declarations static Regex _expression; Match _match; const string _IDExpression = @"(?<Year>[0-9][0-9])(?<Month>([0][1-9])|([1][0-2]))(?<Day>([0-2][0-9])|([3][0-1]))(?<Gender>[0-9])(?<Series>[0-9]{3})(?<Citizenship>[0-9])(?<Uniform>[0-9])(?<Control>[0-9])"; #endregion #region Constuctors /// <summary> /// Sets up the shared objects for ID validation. /// </summary> static IdentityNumber() { _expression = new Regex(_IDExpression, RegexOptions.Compiled | RegexOptions.Singleline); } /// <summary> /// Creates the ID number from a string. /// </summary> /// <param name="IDNumber">The string ID number.</param> public IdentityNumber(string IDNumber) { _match = _expression.Match(IDNumber.Trim()); } #endregion #region Properties /// <summary> /// Indicates the date of birth encoded in the ID Number. /// </summary> /// <exception cref="System.ArgumentException">Thrown if the ID Number is not usable.</exception> public DateTime DateOfBirth { get { if(IsUsable == false) { throw new ArgumentException("ID Number is unusable!", "IDNumber"); } int year = int.Parse(_match.Groups["Year"].Value); // NOTE: Do not optimize by moving these to static, otherwise the calculation may be incorrect // over year changes, especially century changes. int currentCentury = int.Parse(DateTime.Now.Year.ToString().Substring(0, 2) + "00"); int lastCentury = currentCentury - 100; int currentYear = int.Parse(DateTime.Now.Year.ToString().Substring(2, 2)); // If the year is after or at the current YY, then add last century to it, otherwise add // this century. // TODO: YY -> YYYY logic needs thinking about if(year > currentYear) { year += lastCentury; } else { year += currentCentury; } return new DateTime(year, int.Parse(_match.Groups["Month"].Value), int.Parse(_match.Groups["Day"].Value)); } } /// <summary> /// Indicates the gender for the ID number. /// </summary> /// <exception cref="System.ArgumentException">Thrown if the ID Number is not usable.</exception> public PersonGender Gender { get { if(IsUsable == false) { throw new ArgumentException("ID Number is unusable!", "IDNumber"); } int gender = int.Parse(_match.Groups["Gender"].Value); if(gender < (int) PersonGender.Male) { return PersonGender.Female; } else { return PersonGender.Male; } } } /// <summary> /// Indicates the citizenship for the ID number. /// </summary> /// <exception cref="System.ArgumentException">Thrown if the ID Number is not usable.</exception> public PersonCitizenship Citizenship { get { if(IsUsable == false) { throw new ArgumentException("ID Number is unusable!", "IDNumber"); } return (PersonCitizenship) Enum.Parse(typeof(PersonCitizenship), _match.Groups["Citizenship"].Value); } } /// <summary> /// Indicates if the IDNumber is usable or not. /// </summary> public bool IsUsable { get { return _match.Success; } } /// <summary> /// Indicates if the IDNumber is valid or not. /// </summary> public bool IsValid { get { if(IsUsable == true) { // Calculate total A by adding the figures in the odd positions i.e. the first, third, fifth, // seventh, ninth and eleventh digits. int a = int.Parse(_match.Value.Substring(0, 1)) + int.Parse(_match.Value.Substring(2, 1)) + int.Parse(_match.Value.Substring(4, 1)) + int.Parse(_match.Value.Substring(6, 1)) + int.Parse(_match.Value.Substring(8, 1)) + int.Parse(_match.Value.Substring(10, 1)); // Calculate total B by taking the even figures of the number as a whole number, and then // multiplying that number by 2, and then add the individual figures together. int b = int.Parse(_match.Value.Substring(1, 1) + _match.Value.Substring(3, 1) + _match.Value.Substring(5, 1) + _match.Value.Substring(7, 1) + _match.Value.Substring(9, 1) + _match.Value.Substring(11, 1)); b *= 2; string bString = b.ToString(); b = 0; for(int index = 0; index < bString.Length; index++) { b += int.Parse(bString.Substring(index, 1)); } // Calculate total C by adding total A to total B. int c = a + b; // The control-figure can now be determined by subtracting the ones in figure C from 10. string cString = c.ToString() ; cString = cString.Substring(cString.Length - 1, 1) ; int control = 0; // Where the total C is a multiple of 10, the control figure will be 0. if(cString != "0") { control = 10 - int.Parse(cString.Substring(cString.Length - 1, 1)); } if(_match.Groups["Control"].Value == control.ToString()) { return true; } } return false; } } #endregion } } Can someone please tell the syntax for how I pass an id number to the class? Thanks

    Read the article

  • what is wrong with connection string

    - by Hakan
    Can any one help me with this connection string. I can't manage how to fix. Dim constring As String Dim con As SqlCeConnection Dim cmd As SqlCeCommand constring = "(System.IO.Path.GetDirectoryName(System.Reflection.Assembly.GetExecutingAssembly().GetName().CodeBase) + \\database.sdf;Password=pswrd;File Mode=shared read" con = New SqlCeConnection() con.Open() Thanks

    Read the article

  • Struts2 converting empty string parameter to an "int"

    - by Kyle Partridge
    How does one convert an empty string to an int using Struts2. When the application encounters this parameter with no value, like from an empty text field, it throws the following exception. java.lang.NoSuchMethodException: com.XXXXXXXXXXXX.setID([Ljava.lang.String;) Where ID is an integer, and the URL is: Something.action?ID=&other=rawr Is there a way to do this without using an Integer (class)? Do I have to write a type converter?

    Read the article

  • use split() for splitting a string

    - by Hamed
    Hi again... Guys I'd asked 2 questions before and I'd said that I want to split a string like below: Input string: a=aa|b=b||b|c=cc and the output: a=aa b=b||b c=cc some guys answer my question but they use .Match(): var matches = "a=aa|b=b||b|c=cc".match(/(?:[^|]|\|\|)+/g) but I need to use the .split() method and store the outputs in an array. please help me guys... It's so critical... Thanks...

    Read the article

  • convert string of millisecond into datetime in python

    - by newbie
    I am a newbie in Python. I want to substract interval time from my log file, but the problem is I cannot convert millisecond string of log file into datetime format. For example, I have 15:55:05.12345 and I want to remove 5.12345 seconds from this string, and shwow result of 15.55.00.00000 in Python. How can I do that? Currently, I am using python 2.5. Thank you in advance.

    Read the article

  • Error converting datetime to string

    - by user279521
    Hi, I am getting an error when I attempt to display a datetime value in a textbox: My code is: txtStartDate.Text = rdrGetUserInfo.IsDBNull(14) ? String.Empty : Convert.ToString(rdrGetUserInfo.GetString(14)); The error message is: ex.Message = "Unable to cast object of type 'System.DateTime' to type 'System.String'." Any ideas how I can resolve this?

    Read the article

  • Finding tags in query string with regular expression

    - by fatmatto
    Hi everybody! I have to set some routing rules in my php application, and they should be in the form /%var/something/else/%another_var In other words i beed a regex that returns me every URI piece marked by the % character, String marked by % represent var names so they can be almost every string. another example: from /%lang/module/controller/action/%var_1 i want the regex to extract lang and var_1 i tried something like /.*%(.*)[\/$]/ but it doesn't work.....

    Read the article

  • Place images byte into String is not working?

    - by Proyb2
    I tried on Flex 3, facing issue with uploading JPG/PNG image, trace readUTFBytes would return correct bytes length but tmpFileContent is trucated, it would only appear to have upload just 3 characters of data to the server through PHP script which made image unusable. I have no issue for non-images format. What is wrong here? var tmpFileContent:String = fileRef.data.readUTFBytes(fileRef.data.length); Is String capable of handle bytes?

    Read the article

  • What is wrong with this connection string?

    - by Hakan
    Can any one help me with this connection string. I can't manage how to fix. Dim constring As String Dim con As SqlCeConnection Dim cmd As SqlCeCommand constring = "(System.IO.Path.GetDirectoryName(System.Reflection.Assembly.GetExecutingAssembly().GetName().CodeBase) + \\database.sdf;Password=pswrd;File Mode=shared read" con = New SqlCeConnection() con.Open() Thanks

    Read the article

  • Help me to split string with Regular Expression

    - by Lu Lu
    Hello, I have a string: CriteriaCondition={FieldName={*EPS}*$MinValue=(-201)$MaxValue=(304)$TradingPeriod=(-1)} Help me to get the first word which ends with the first word "={" & get the next following word which ends with "}". The result must be: Word1 = "CriteriaCondition" Word2 = "FieldName={EPS}$MinValue=(-201)$MaxValue=(304)$TradingPeriod=(-1)" And with the string "FieldName=(EPS)$MinValue=(-201)$MaxValue=(304)$TradingPeriod=(-1)", help me to split to pairs: FieldName EPS MinValue -201 MaxValue 304 TradingPeriod -1 Thanks.

    Read the article

  • How to combine array list string in java ?

    - by tiendv
    I have some arraylist string with keyword inside like that ! A windows is arraylist string with keyword is bold Struct of window : 9 words before + keyword + 9 words after You can see some window overlaping How to i combine that arraylist to receive like that : Thanks

    Read the article

  • In php, Prepare string and create XML/RSS Feed

    - by Bill
    I want to create my own RSS/XML feed. I fetch data from the database to display, but keep getting invalid character errors. If the string has an ampersand or other strange characters in it, the XML will be invalid. I tried using urlencode and htmlentities, but these don't capture all possible characters which need to be escaped. Does anyone know of a PHP function which will prepare a string for XML output?

    Read the article

  • Base X string encoding

    - by Paul Stone
    I'm looking for a routine that will encode a string (stream of bytes) into an arbitrary base/alphabet (like base64 encoding but I get to choose the alphabet). I've seen a few routines that do base X encoding for a number, but not for a string.

    Read the article

  • File details from a string in C#

    - by acadia
    Hello, I have a string in C# String file="\\mserver-80\docs\somedoc.doc" Now How do I get fileInfo from the above sting. What I mean is, I want to declare something like FileInfo fInfo = new FileInfo(file); fileExtn = fInfo.Extension;

    Read the article

  • How to Convert arrays or SimpleXML-Objects into an XML-String

    - by streetparade
    I want to create a xml from a given string, i have a function but i didn't wrote it.It seems a bit cryptical too. Can please some one review it and give me some Ideas, how it could be written clearer for everybody? /** * Converts arrays or SimpleXML-Objects into an XML-String * @params mixed Accepts an array or xml string with data to Post * @params integer DO NOT PROVIDE. Internal Usage for recursion only */ private function mixedDataToXML($data, $level = 1) { if(!$data){ return FALSE; } if(is_array($data)) { $xml = ''; if ($level==1) { $xml .= '<?xml version="1.0" encoding="ISO-8859-1"?>'."\n"; } foreach ($data as $key => $value) { $key = strtolower($key); if (is_array($value)) { $multi_tags = false; foreach($value as $key2=>$value2) { if (is_array($value2)) { $xml .= str_repeat("\t",$level)."<$key>\n"; $xml .= $this->mixedDataToXML($value2, $level+1); $xml .= str_repeat("\t",$level)."</$key>\n"; $multi_tags = true; } else { if (trim($value2)!='') { if (htmlspecialchars($value2)!=$value2) { $xml .= str_repeat("\t",$level). "<$key><![CDATA[$value2]]>". "</$key>\n"; } else { $xml .= str_repeat("\t",$level). "<$key>$value2</$key>\n"; } } $multi_tags = true; } } if (!$multi_tags and count($value)>0) { $xml .= str_repeat("\t",$level)."<$key>\n"; $xml .= $this->mixedDataToXML($value, $level+1); $xml .= str_repeat("\t",$level)."</$key>\n"; } } else { if (trim($value)!='') { if (htmlspecialchars($value)!=$value) { $xml .= str_repeat("\t",$level)."<$key>". "<![CDATA[$value]]></$key>\n"; } else { $xml .= str_repeat("\t",$level). "<$key>$value</$key>\n"; } } } } return $xml; }else{ return (string)$data; } }

    Read the article

  • Converting a time_t to string

    - by wyatt
    I have a time_t variable containing a timestamp which I'd like to store in a database, so I need it as a string. How would I convert it. Also, on the subject, how would I convert a timestamp string into a time_t varible? Thanks, Wyatt

    Read the article

  • Converting string to email-attachment on android

    - by sandis
    So I have som data that I have converted to a string. While I have found how to attach something from the SD-card to a mail, I cant figure out how to directly convert my string to a mail-attachment without involving the SD-card. In case it holds significance, I have read some data from a database, converted it to csv-format, and now wants to attach it as a csv-file. Cheers,

    Read the article

  • C++ string template library

    - by Gopalakrishnan Subramani
    I want simple C++ string based template library to replace strings at runtime. For example, I will use string template = "My name is {{name}}"; At runtime, I want the name to be changed based on actual one. I found one example, www.stringtemplate.org but I little scared when its talks about antlr etc.

    Read the article

  • Extracting a string between specified characters in python

    - by Seth
    I'm a newbie to regular expressions and I have the following string: sequence = ["{\"First\":\"Belyuen,NT,0801\",\"Second\":\"Belyuen,NT,0801\"}","{\"First\":\"Larrakeyah,NT,0801\",\"Second\":\"Larrakeyah,NT,0801\"}"] I am trying to extract the text Belyuen,NT,0801 and Larrakeyah,NT,0801 in python. I have the following code which is not working: re.search('\:\\"...\\', ''.join(sequence)) I.e. I want to get the string between characters :\ and \.

    Read the article

  • Tool to recursively search all files in a directory for a string [closed]

    - by routeNpingme
    Possible Duplicate: Tools to search for strings inside files without indexing Before I make one, any good tools out there for free/cheap that will recurse through all files in a directory and search for a text string in them? Need to find an instance of a string in any configuration files laying around. Kind of like a Windows Search "find files that contain..." on steroids? Oops - This is pretty much a duplicate question, sorry, didn't find the other one before

    Read the article

< Previous Page | 107 108 109 110 111 112 113 114 115 116 117 118  | Next Page >