Search Results

Search found 37183 results on 1488 pages for 'string conversion'.

Page 128/1488 | < Previous Page | 124 125 126 127 128 129 130 131 132 133 134 135  | Next Page >

  • notepad++ to search a line for varied strings. advanced commands

    - by Capum
    here it is [email protected], Charles Dawson [email protected], [email protected], [email protected], [email protected], [email protected], [email protected], Queen Roffman [email protected], [email protected], [email protected], [email protected], [email protected], [email protected], Wanda Ximenes [email protected], [email protected], I want to remove the strings before the 'emails' therefore only remains the 'emails at example dot example' seperated by comma. Also, I want to search for any repeated or duplicated terms or words in all text. What command for that purpose would reply me '[email protected]' ?

    Read the article

  • How do I initialize a Scala map with more than 4 initial elements in Java?

    - by GlenPeterson
    For 4 or fewer elements, something like this works (or at least compiles): import scala.collection.immutable.Map; Map<String,String> HAI_MAP = new Map4<>("Hello", "World", "Happy", "Birthday", "Merry", "XMas", "Bye", "For Now"); For a 5th element I could do this: Map<String,String> b = HAI_MAP.$plus(new Tuple2<>("Later", "Aligator")); But I want to know how to initialize an immutable map with 5 or more elements and I'm flailing in Type-hell. Partial Solution I thought I'd figure this out quickly by compiling what I wanted in Scala, then decompiling the resultant class files. Here's the scala: object JavaMapTest { def main(args: Array[String]) = { val HAI_MAP = Map(("Hello", "World"), ("Happy", "Birthday"), ("Merry", "XMas"), ("Bye", "For Now"), ("Later", "Aligator")) println("My map is: " + HAI_MAP) } } But the decompiler gave me something that has two periods in a row and thus won't compile (I don't think this is valid Java): scala.collection.immutable.Map HAI_MAP = (scala.collection.immutable.Map) scala.Predef..MODULE$.Map().apply(scala.Predef..MODULE$.wrapRefArray( scala.Predef.wrapRefArray( (Object[])new Tuple2[] { new Tuple2("Hello", "World"), new Tuple2("Happy", "Birthday"), new Tuple2("Merry", "XMas"), new Tuple2("Bye", "For Now"), new Tuple2("Later", "Aligator") })); I'm really baffled by the two periods in this: scala.Predef..MODULE$ I asked about it on #java on Freenode and they said the .. looked like a decompiler bug. It doesn't seem to want to compile, so I think they are probably right. I'm running into it when I try to browse interfaces in IntelliJ and am just generally lost. Based on my experimentation, the following is valid: Tuple2[] x = new Tuple2[] { new Tuple2<String,String>("Hello", "World"), new Tuple2<String,String>("Happy", "Birthday"), new Tuple2<String,String>("Merry", "XMas"), new Tuple2<String,String>("Bye", "For Now"), new Tuple2<String,String>("Later", "Aligator") }; scala.collection.mutable.WrappedArray<Tuple2> y = scala.Predef.wrapRefArray(x); There is even a WrappedArray.toMap() method but the types of the signature are complicated and I'm running into the double-period problem there too when I try to research the interfaces from Java.

    Read the article

  • Getting Pango-WARNING: Invalid UTF-8 string passed to pango_layout_set_text()

    - by geerlingguy
    About three days ago, I noticed the exim mailqueue started filling up on one of my servers, and upon inspecting some of the emails using # exim -Mvb $ID, I noticed they were being sent to some system email address (which is not a real address), and the body of the messages were as follows: (process:8259): Pango-WARNING **: Invalid UTF-8 string passed to pango_layout_set_text() I'm wondering what could be causing this strange issue, as I've never heard of 'pango' at all... I've never seen that function used in my lifetime! It seems the process id (PID) is for an apache process, though, as the pids are always gone by the time I use # ps -aux to look them up. Edit: Whoops! Forgot to include the subject - looks like it's actually munin-cron that's bringing up the issue: Subject: Cron /usr/bin/munin-cron --force-root

    Read the article

  • Photoshop / Illustrator Fill text box with large string.

    - by Xetius
    I have a massive string (lots of Fibonacci numbers concatenated together). I don't know how much of this text I need to fill an A4 page. What I was hoping for was to paste a large block into a text box and have it display as much as possible, wrapping the text at the end of a line, but it is not doing that. It is just displaying a blank box (With the text overflowing into an awaiting textbox or something. I have tried pasting smaller amounts of text into the text box, and it appears that it will get about half way and then go into 'blank' mode. All I need is a simple way of creating a background of numbers which I don't have to type in. Any ideas?

    Read the article

  • Long string insertion with sed

    - by Luis Varca
    I am trying to use this expression to insert the contents of one text file into another after a give string. This is a simple bash script: TEXT=`cat file1.txt` sed -i "/teststring/a \ $TEXT" file2.txt This returns an error, "sed: -e expression #1, char 37: unknown command: `M'" The issue is in the fact that the contents of file1.txt are actually a private certificate so it's a large amount of text and unusual characters which seems to be causing an issue. If I replace $TEXT with a simple ASCII value it works but when it reads the large content of file1.txt it fails with that error. Is there some way to carry out this action? Is my syntax off with sed or my quote placement wrong?

    Read the article

  • Powershell SQL query--connection string

    - by sean
    I am trying to query several different SQL servers and run a command on each of them. I am unable to get the connection string right. Code, below. I receive the following error:Login failed. The login is from an untrusted domain and cannot be used with Windows authentication. I thought if I passed it the credentials it wouldn't care about the domain. How do I get around this? Thanks in advance. $serverList = @(Get-Content "c:\AllServers.txt") $query = "SELECT COUNT(thing) AS [RowCount] FROM My_table" $Database = "My_DB" # Read a file foreach ( $svr in $serverList ) { $conn=new-object System.Data.SqlClient.SQLConnection $ConnectionString = "Server={0};Database={1};User ID=sa;Password=Password;Integrated Security=True" -f $svr, $Database $conn.ConnectionString=$ConnectionString $conn.Open() $cmd=new-object system.Data.SqlClient.SqlCommand($Query,$conn) $conn.Close() }

    Read the article

  • Single line diff

    - by Ollie Saunders
    Is there a diff tool I can run from the command line or maybe just an online webpage that will compare single lines? GitHub diffs do this but I'm don't want to publish things to GitHub just to read the diffs! This is the sort of thing I'm wanting to diff: a:2:{i:0;O:10:"FuTreeNode":6:{s:5:"outer";r:2;s:6:"inners";O:20:"FuLinkedTreeNodeList":2:{s:5:"outer";r:2;s:5:"items";a:0:{}}s:5:"value";s:3:"foo";s:4:"next";O:10:"FuTreeNode":6:{s:5:"outer";r:2;s:6:"inners";O:20:"FuLinkedTreeNodeList":2:{s:5:"outer";r:8;s:5:"items";a:0:{}}s:5:"value";s:3:"bar";s:4:"next";N;s:4:"prev";O:10:"FuTreeNode":6:{s:5:"outer";N;s:6:"inners";O:20:"FuLinkedTreeNodeList":2:{s:5:"outer";r:15;s:5:"items";a:0:{}}s:5:"value";s:3:"zim";s:4:"next";r:8;s:4:"prev";O:10:"FuTreeNode":6:{s:5:"outer";N;s:6:"inners";O:20:"FuLinkedTreeNodeList":2:{s:5:"outer";r:22;s:5:"items";a:0:{}}s:5:"value";s:3:"foo";s:4:"next";r:15;s:4:"prev";r:8;s:6:"ofList";O:12:"FuLinkedList":1:{s:5:"items";a:4:{i:0;r:2;i:1;r:8;i:2;r:22;i:3;r:15;}}}s:6:"ofList";r:30;}s:6:"ofList";O:20:"FuLinkedTreeNodeList":2:{s:5:"outer";r:2;s:5:"items";a:2:{i:0;r:2;i:1;r:8;}}}s:4:"prev";N;s:6:"ofList";r:37;}i:1;r:8;} a:2:{i:0;O:10:"FuTreeNode":6:{s:5:"outer";r:2;s:6:"inners";O:20:"FuLinkedTreeNodeList":2:{s:5:"outer";r:2;s:5:"items";a:0:{}}s:5:"value";s:3:"foo";s:4:"next";O:10:"FuTreeNode":6:{s:5:"outer";r:2;s:6:"inners";O:20:"FuLinkedTreeNodeList":2:{s:5:"outer";r:8;s:5:"items";a:0:{}}s:5:"value";s:3:"bar";s:4:"next";N;s:4:"prev";O:10:"FuTreeNode":6:{s:5:"outer";N;s:6:"inners";O:20:"FuLinkedTreeNodeList":2:{s:5:"outer";r:15;s:5:"items";a:0:{}}s:5:"value";s:3:"zim";s:4:"next";r:8;s:4:"prev";O:10:"FuTreeNode":6:{s:5:"outer";N;s:6:"inners";O:20:"FuLinkedTreeNodeList":2:{s:5:"outer";r:22;s:5:"items";a:0:{}}s:5:"value";s:3:"foo";s:4:"next";r:15;s:4:"prev";r:8;s:6:"ofList";O:12:"FuLinkedList":1:{s:5:"items";a:4:{i:0;r:2;i:1;r:8;i:2;r:22;i:3;r:15;}}}s:6:"ofList";r:30;}s:6:"ofList";O:20:"FuLinkedTreeNodeList":2:{s:5:"outer";r:2;s:5:"items";a:2:{i:0;r:2;i:1;r:8;}}}s:4:"prev";N;s:6:"ofList";r:37;}i:1;r:22;} I'm on Mac OS X.

    Read the article

  • PhoneGap Build 1.0 : Adobe relance son outil de conversion d'applications mobiles multiplateforme et enrichit son offre Cloud

    PhoneGap Build 1.0 : Adobe relance l'outil de conversion d'applications mobiles multiplateforme Et enrichit son offre Cloud avec 5 autres services Dans le cadre de sa conférence Create theWeb, Adobe a dévoilé hier une palette d'outils et de services pour les designers et les développeurs. Des outils très orientés HTML5, CSS3 et JavaScript. Leur but : « créer plus facilement des sites web, des contenus numériques et des applications mobiles ». La liste est assez longue. On y trouve PhoneGap Build 1.0 et une gamme Edge qui se compose à présent de Edge Animate 1.0, EdgeInspect 1.0 (ex-Shadow), Edge Web Fonts, Edge Code et en avant-première Edge Reflow.

    Read the article

  • Project Server 2010 site creation - the database connection string is not available

    - by Brandon Montgomery
    I am trying to get Project Server 2010 up and running on a Win Server 2008 box. I've got Sharepoint 2010 installed and Project Server 2010 installed. I open SharePoint Central Administration, then I go to Manage Service Applications Project Server Service Application. It looks like there is a site under the "Sharepoint - 80" section, but the Status says "Failed - see the Application event Log". When I click on the site and select "Retry" I get the same thing. In the event viewer, I see an error with SharePoint Foundation Search as the Source - it reads: Could not create a database session. Context: Application '276504a6-93b1-4c1f-a900-fd6ed9d5c117' Details: The database connection string is not available. (0xc0041228) How can I fix this? Is there some configuration I missed?

    Read the article

  • How do I find files containing two strings together in Linux?

    - by alwbtc
    I have a file containing a text: PADLST20120907:D:05B:UN:IBTA+TK4 17 JFL01+01'BGM+250+C'RFF+TN:TK4 I want to find this file in Linux, using these two strings: "JFL" and "20120907". As you see above, the file contains both "JFL" and "20120907". What should I write in command line? Stirngs may or may not be in the same line. I want to see file names with full path in the output. I don't want to see error messages or permission denied warnings. I want to search recursively in the directory I am standing in or I would like to specifiy a path. regards

    Read the article

  • Notepad++ or other application to replace string with numeric function

    - by user38963
    Hello. I am using Notepad++ and attempting to replace all numeric strings within a specific tag (xxxxof my XML document with a new string which has been modified by a specific variable. Here's an example (please remove the space between < and start): < start501234< /start round(501234 * 0.9) = 451111 < start451111< /start Is there a way to automatically find all numeric values within the start tag and do replace it by that same value multiplied by 0.9? I don't have to use Notepad++ if there's another tool that can do this. Thanks!

    Read the article

  • Linux (lsusb) not showing String Descriptors of a USB device

    - by tzippy
    I have an embedded device that when plugged to a linux host, shows up with vid and pid that are not in the usb.ids file (proprietary IDs). However I provide String Descriptors that do show up when plugged into a Windows Host. But not on a Linux Host. lsusb -v shows only iManufacturer 3 iProduct 2 iSerial 1 But on the device side, when processing the setup requests, I see that the Strings are actually requested by the Host. By Windows and also the Linux Host. The USB Device Tree Viewwer under Windows shows this output: iManufacturer : 0x01 Language 0x0409 : "My Manufacturer" iProduct : 0x02 Language 0x0409 : "MyProduct" iSerialNumber : 0x03 Language 0x0409 : "My Serial" I feel that lsusb does not show all of the information. Is there a more informative tool?

    Read the article

  • how to insert data if it contain apostrophe ?

    - by angel ansari
    Actally my task is load csv file into sql server using c# so i have split it by comma my problem is that some field's data contain apostrop and i m firing insert query to load data into sql so its give error my coding like that using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Linq; using System.Text; using System.Windows.Forms; using System.IO; using System.Data.SqlClient; namespace tool { public partial class Form1 : Form { StreamReader reader; SqlConnection con; SqlCommand cmd; int count = 0; //int id=0; FileStream fs; string file = null; string file_path = null; SqlCommand sql_del = null; public Form1() { InitializeComponent(); } private void button1_Click(object sender, EventArgs e) { OpenFileDialog file1 = new OpenFileDialog(); file1.ShowDialog(); textBox1.Text = file1.FileName.ToString(); file = Path.GetFileName(textBox1.Text); file_path = textBox1.Text; fs = new FileStream(file_path, FileMode.Open, FileAccess.Read); } private void button2_Click(object sender, EventArgs e) { if (file != null ) { sql_del = new SqlCommand("Delete From credit_debit1", con); sql_del.ExecuteNonQuery(); reader = new StreamReader(file_path); string line_content = null; string[] items = new string[] { }; while ((line_content = reader.ReadLine()) != null) { if (count >=4680) { items = line_content.Split(','); string region = items[0].Trim('"'); string station = items[1].Trim('"'); string ponumber = items[2].Trim('"'); string invoicenumber = items[3].Trim('"'); string invoicetype = items[4].Trim('"'); string filern = items[5].Trim('"'); string client = items[6].Trim('"'); string origin = items[7].Trim('"'); string destination = items[8].Trim('"'); string agingdate = items[9].Trim('"'); string activitydate = items[10].Trim('"'); if ((invoicenumber == "-") || (string.IsNullOrEmpty(invoicenumber))) { invoicenumber = "null"; } else { invoicenumber = "'" + invoicenumber + "'"; } if ((destination == "-") || (string.IsNullOrEmpty(destination))) { destination = "null"; } else { destination = "'" + destination + "'"; } string vendornumber = items[11].Trim('"'); string vendorname = items[12].Trim('"'); string vendorsite = items[13].Trim('"'); string vendorref = items[14].Trim('"'); string subaccount = items[15].Trim('"'); string osdaye = items[16].Trim('"'); string osaa = items[17].Trim('"'); string osda = items[18].Trim('"'); string our = items[19].Trim('"'); string squery = "INSERT INTO credit_debit1" + "([id],[Region],[Station],[PONumber],[InvoiceNumber],[InvoiceType],[FileRefNumber],[Client],[Origin],[Destination], " + "[AgingDate],[ActivityDate],[VendorNumber],[VendorName],[VendorSite],[VendorRef],[SubAccount],[OSDay],[OSAdvAmt],[OSDisbAmt], " + "[OverUnderRecovery] ) " + "VALUES " + "('" + count + "','" + region + "','" + station + "','" + ponumber + "'," + invoicenumber + ",'" + invoicetype + "','" + filern + "','" + client + "','" + origin + "'," + destination + "," + "'" + (string)agingdate.ToString() + "','" + (string)activitydate.ToString() + "','" + vendornumber + "',' " + vendorname + "',' " + vendorsite + "',' " + vendorref + "'," + "'" + subaccount + "','" + osdaye + "','" + osaa + "','" + osda + "','" + our + "') "; cmd = new SqlCommand(squery, con); cmd.CommandTimeout = 1500; cmd.ExecuteNonQuery(); } label2.Text = count.ToString(); Application.DoEvents(); count++; } MessageBox.Show("Process completed"); } else { MessageBox.Show("path select"); } } private void button3_Click(object sender, EventArgs e) { this.Close(); } private void Form1_Load(object sender, EventArgs e) { con = new SqlConnection("Data Source=192.168.50.200;User ID=EGL_TEST;Password=TEST;Initial Catalog=EGL_TEST;"); con.Open(); } } } vendername field contain data (MCCOLLISTER'S TRANSPORTATION) so how to pass this data

    Read the article

  • .NET: Interface Problem VB.net Getter Only Interface

    - by snmcdonald
    Why does an interface override a class definition and violate class encapsulation? I have included two samples below, one in C# and one in VB.net? VB.net Module Module1 Sub Main() Dim testInterface As ITest = New TestMe Console.WriteLine(testInterface.Testable) ''// Prints False testInterface.Testable = True ''// Access to Private!!! Console.WriteLine(testInterface.Testable) ''// Prints True Dim testClass As TestMe = New TestMe Console.WriteLine(testClass.Testable) ''// Prints False ''//testClass.Testable = True ''// Compile Error Console.WriteLine(testClass.Testable) ''// Prints False End Sub End Module Public Class TestMe : Implements ITest Private m_testable As Boolean = False Public Property Testable As Boolean Implements ITest.Testable Get Return m_testable End Get Private Set(ByVal value As Boolean) m_testable = value End Set End Property End Class Interface ITest Property Testable As Boolean End Interface C# using System; using System.Collections.Generic; using System.Linq; using System.Text; namespace InterfaceCSTest { class Program { static void Main(string[] args) { ITest testInterface = new TestMe(); Console.WriteLine(testInterface.Testable); testInterface.Testable = true; Console.WriteLine(testInterface.Testable); TestMe testClass = new TestMe(); Console.WriteLine(testClass.Testable); //testClass.Testable = true; Console.WriteLine(testClass.Testable); } } class TestMe : ITest { private bool m_testable = false; public bool Testable { get { return m_testable; } private set { m_testable = value; } } } interface ITest { bool Testable { get; set; } } } More Specifically How do I implement a interface in VB.net that will allow for a private setter. For example in C# I can declare: class TestMe : ITest { private bool m_testable = false; public bool Testable { get { return m_testable; } private set //No Compile Error here! { m_testable = value; } } } interface ITest { bool Testable { get; } } However, if I declare an interface property as readonly in VB.net I cannot create a setter. If I create a VB.net interface as just a plain old property then interface declarations will violate my encapsulation. Public Class TestMe : Implements ITest Private m_testable As Boolean = False Public ReadOnly Property Testable As Boolean Implements ITest.Testable Get Return m_testable End Get Private Set(ByVal value As Boolean) ''//Compile Error m_testable = value End Set End Property End Class Interface ITest ReadOnly Property Testable As Boolean End Interface So my question is, how do I define a getter only Interface in VB.net with proper encapsulation? I figured the first example would have been the best method. However, it appears as if interface definitions overrule class definitions. So I tried to create a getter only (Readonly) property like in C# but it does not work for VB.net. Maybe this is just a limitation of the language?

    Read the article

  • how to insert data if it contain apostrop ?

    - by angel ansari
    Actally my task is load csv file into sql server using c# so i have split it by comma my problem is that some field's data contain apostrop and i m firing insert query to load data into sql so its give error my coding like that using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Linq; using System.Text; using System.Windows.Forms; using System.IO; using System.Data.SqlClient; namespace tool { public partial class Form1 : Form { StreamReader reader; SqlConnection con; SqlCommand cmd; int count = 0; //int id=0; FileStream fs; string file = null; string file_path = null; SqlCommand sql_del = null; public Form1() { InitializeComponent(); } private void button1_Click(object sender, EventArgs e) { OpenFileDialog file1 = new OpenFileDialog(); file1.ShowDialog(); textBox1.Text = file1.FileName.ToString(); file = Path.GetFileName(textBox1.Text); file_path = textBox1.Text; fs = new FileStream(file_path, FileMode.Open, FileAccess.Read); } private void button2_Click(object sender, EventArgs e) { if (file != null ) { sql_del = new SqlCommand("Delete From credit_debit1", con); sql_del.ExecuteNonQuery(); reader = new StreamReader(file_path); string line_content = null; string[] items = new string[] { }; while ((line_content = reader.ReadLine()) != null) { if (count >=4680) { items = line_content.Split(','); string region = items[0].Trim('"'); string station = items[1].Trim('"'); string ponumber = items[2].Trim('"'); string invoicenumber = items[3].Trim('"'); string invoicetype = items[4].Trim('"'); string filern = items[5].Trim('"'); string client = items[6].Trim('"'); string origin = items[7].Trim('"'); string destination = items[8].Trim('"'); string agingdate = items[9].Trim('"'); string activitydate = items[10].Trim('"'); if ((invoicenumber == "-") || (string.IsNullOrEmpty(invoicenumber))) { invoicenumber = "null"; } else { invoicenumber = "'" + invoicenumber + "'"; } if ((destination == "-") || (string.IsNullOrEmpty(destination))) { destination = "null"; } else { destination = "'" + destination + "'"; } string vendornumber = items[11].Trim('"'); string vendorname = items[12].Trim('"'); string vendorsite = items[13].Trim('"'); string vendorref = items[14].Trim('"'); string subaccount = items[15].Trim('"'); string osdaye = items[16].Trim('"'); string osaa = items[17].Trim('"'); string osda = items[18].Trim('"'); string our = items[19].Trim('"'); string squery = "INSERT INTO credit_debit1" + "([id],[Region],[Station],[PONumber],[InvoiceNumber],[InvoiceType],[FileRefNumber],[Client],[Origin],[Destination], " + "[AgingDate],[ActivityDate],[VendorNumber],[VendorName],[VendorSite],[VendorRef],[SubAccount],[OSDay],[OSAdvAmt],[OSDisbAmt], " + "[OverUnderRecovery] ) " + "VALUES " + "('" + count + "','" + region + "','" + station + "','" + ponumber + "'," + invoicenumber + ",'" + invoicetype + "','" + filern + "','" + client + "','" + origin + "'," + destination + "," + "'" + (string)agingdate.ToString() + "','" + (string)activitydate.ToString() + "','" + vendornumber + "',' " + vendorname + "',' " + vendorsite + "',' " + vendorref + "'," + "'" + subaccount + "','" + osdaye + "','" + osaa + "','" + osda + "','" + our + "') "; cmd = new SqlCommand(squery, con); cmd.CommandTimeout = 1500; cmd.ExecuteNonQuery(); } label2.Text = count.ToString(); Application.DoEvents(); count++; } MessageBox.Show("Process completed"); } else { MessageBox.Show("path select"); } } private void button3_Click(object sender, EventArgs e) { this.Close(); } private void Form1_Load(object sender, EventArgs e) { con = new SqlConnection("Data Source=192.168.50.200;User ID=EGL_TEST;Password=TEST;Initial Catalog=EGL_TEST;"); con.Open(); } } } vendername field contain data (MCCOLLISTER'S TRANSPORTATION) so how to pass this data

    Read the article

  • C# Reading and Writing a Char[] to and from a Byte[]

    - by Simon G
    Hi, I have a byte array of around 10,000 bytes which is basically a blob from delphi that contains char, string, double and arrays of various types. This need to be read in and updated via C#. I've created a very basic reader that gets the byte array from the db and converts the bytes to the relevant object type when accessing the property which works fine. My problem is when I try to write to a specific char[] item, it doesn't seem to update the byte array. I've created the following extensions for reading and writing: public static class CharExtension { public static byte ToByte( this char c ) { return Convert.ToByte( c ); } public static byte ToByte( this char c, int position, byte[] blob ) { byte b = c.ToByte(); blob[position] = b; return b; } } public static class CharArrayExtension { public static byte[] ToByteArray( this char[] c ) { byte[] b = new byte[c.Length]; for ( int i = 1; i < c.Length; i++ ) { b[i] = c[i].ToByte(); } return b; } public static byte[] ToByteArray( this char[] c, int positon, int length, byte[] blob ) { byte[] b = c.ToByteArray(); Array.Copy( b, 0, blob, positon, length ); return b; } } public static class ByteExtension { public static char ToChar( this byte[] b, int position ) { return Convert.ToChar( b[position] ); } } public static class ByteArrayExtension { public static char[] ToCharArray( this byte[] b, int position, int length ) { char[] c = new char[length]; for ( int i = 0; i < length; i++ ) { c[i] = b.ToChar( position ); position += 1; } return c; } } to read and write chars and char arrays my code looks like: Byte[] _Blob; // set from a db field public char ubin { get { return _tariffBlob.ToChar( 14 ); } set { value.ToByte( 14, _Blob ); } } public char[] usercaplas { get { return _tariffBlob.ToCharArray( 2035, 10 ); } set { value.ToByteArray( 2035, 10, _Blob ); } } So to write to the objects I can do: ubin = 'C'; // this will update the byte[] usercaplas = new char[10] { 'A', 'B', etc. }; // this will update the byte[] usercaplas[3] = 'C'; // this does not update the byte[] I know the reason is that the setter property is not being called but I want to know is there a way around this using code similar to what I already have? I know a possible solution is to use a private variable called _usercaplas that I set and update as needed however as the byte array is nearly 10,000 bytes in length the class is already long and I would like a simpler approach as to reduce the overall code length and complexity. Thank

    Read the article

  • Choosing a type for search results in C#

    - by Chris M
    I have a result set that will never exceed 500; the results that come back from the web-service are assigned to a search results object. The data from the webservice is about 2mb; the bit I want to use is about a third of each record, so this allows me to cache and quickly manipulate it. I want to be able to sort and filter the results with the least amount of overhead and as fast as possible so I used the VCSKICKS timing class to measure their performance Average Total (10,000) Type Create Sort Create Sort HashSet 0.1579 0.0003 1579 3 IList 0.0633 0.0002 633 2 IQueryable 0.0072 0.0432 72 432 Measured in Seconds using http://www.vcskicks.com/algorithm-performance.php I created the hashset through a for loop over the web-service response (adding to the hashset). The List & IQueryable were created using LINQ. Question I can understand why HashSet takes longer to create (the foreach loop vs linq); but why would IQueryable take longer to sort than the other two; and finally is there a better way to assign the HashSet. Thanks Actual Program public class Program { private static AuthenticationHeader _authHeader; private static OPSoapClient _opSession; private static AccommodationSearchResponse _searchResults; private static HashSet<SearchResults> _myHash; private static IList<SearchResults> _myList; private static IQueryable<SearchResults> _myIQuery; static void Main(string[] args) { #region Setup WebService _authHeader = new AuthenticationHeader { UserName = "xx", Password = "xx" }; _opSession = new OPSoapClient(); #region Setup Search Results _searchResults = _opgSession.SearchCR(_authHeader, "ENG", "GBP", "GBR"); #endregion Setup Search Results #endregion Setup WebService // HASHSET SpeedTester hashTest = new SpeedTester(TestHashSet); hashTest.RunTest(); Console.WriteLine("- Hash Test \nAverage Running Time: {0}; Total Time: {1}", hashTest.AverageRunningTime, hashTest.TotalRunningTime); SpeedTester hashSortTest = new SpeedTester(TestSortingHashSet); hashSortTest.RunTest(); Console.WriteLine("- Hash Sort Test \nAverage Running Time: {0}; Total Time: {1}", hashSortTest.AverageRunningTime, hashSortTest.TotalRunningTime); // ILIST SpeedTester listTest = new SpeedTester(TestList); listTest.RunTest(); Console.WriteLine("- List Test \nAverage Running Time: {0}; Total Time: {1}", listTest.AverageRunningTime, listTest.TotalRunningTime); SpeedTester listSortTest = new SpeedTester(TestSortingList); listSortTest.RunTest(); Console.WriteLine("- List Sort Test \nAverage Running Time: {0}; Total Time: {1}", listSortTest.AverageRunningTime, listSortTest.TotalRunningTime); // IQUERIABLE SpeedTester iqueryTest = new SpeedTester(TestIQueriable); iqueryTest.RunTest(); Console.WriteLine("- iquery Test \nAverage Running Time: {0}; Total Time: {1}", iqueryTest.AverageRunningTime, iqueryTest.TotalRunningTime); SpeedTester iquerySortTest = new SpeedTester(TestSortableIQueriable); iquerySortTest.RunTest(); Console.WriteLine("- iquery Sort Test \nAverage Running Time: {0}; Total Time: {1}", iquerySortTest.AverageRunningTime, iquerySortTest.TotalRunningTime); } static void TestHashSet() { var test = _searchResults.Items; _myHash = new HashSet<SearchResults>(); foreach(var x in test) { _myHash.Add(new SearchResults { Ref = x.Ref, Price = x.StandardPrice }); } } static void TestSortingHashSet() { var sorted = _myHash.OrderBy(s => s.Price); } static void TestList() { var test = _searchResults.Items; _myList = (from x in test select new SearchResults { Ref = x.Ref, Price = x.StandardPrice }).ToList(); } static void TestSortingList() { var sorted = _myList.OrderBy(s => s.Price); } static void TestIQueriable() { var test = _searchResults.Items; _myIQuery = (from x in test select new SearchResults { Ref = x.Ref, Price = x.StandardPrice }).AsQueryable(); } static void TestSortableIQueriable() { var sorted = _myIQuery.OrderBy(s => s.Price); } }

    Read the article

  • Why ((Integer) weightModel.getObject()).intValue(); throws exception

    - by yakup
    I am learning Wicket by "Enjoying Web Development with Wicket" book. And in an example: int weight = ((Integer) weightModel.getObject()).intValue(); is used. When I click Submit button it throws exception. But after changed the code to: int weight=Integer.parseInt( (String) weightModel.getObject()); It works fine. What is the reason for throwing the exception? The full code: GetRequest.java package myapp.postage; import java.util.HashMap; import java.util.Map; import org.apache.wicket.markup.html.WebPage; import org.apache.wicket.markup.html.form.Form; import org.apache.wicket.markup.html.form.TextField; import org.apache.wicket.model.Model; @SuppressWarnings("unchecked") public class GetRequest extends WebPage { private Model weightModel=new Model(); private Model patronCodeModel=new Model(); private Map patronCodeToDiscount; public GetRequest(){ patronCodeToDiscount=new HashMap(); patronCodeToDiscount.put("p1", new Integer(90)); patronCodeToDiscount.put("p2", new Integer(95)); Form form=new Form("form"){ @Override protected void onSubmit(){ int weight = ((Integer) weightModel.getObject()).intValue(); Integer discount=(Integer)patronCodeToDiscount.get(patronCodeModel.getObject()); int postagePerKg=10; int postage=weight*postagePerKg; if(discount!=null){ postage=postage*discount.intValue()/100; } ShowPostage showPostage=new ShowPostage(postage); setResponsePage(showPostage); } }; TextField weight=new TextField("weight",weightModel); form.add(weight); TextField patronCode=new TextField("patronCode",patronCodeModel); form.add(patronCode); add(form); } } The html file GetRequest.html: <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> <html> <form wicket:id="form"> <table> <tr> <td>Weight</td> <td><input type="text" wicket:id="weight"/></td> </tr> <tr> <td>Patron code:</td> <td><input type="text" wicket:id="patronCode"/></td> </tr> <tr> <td></td> <td><input type="submit"/></td> </tr> </table> </form> </html>

    Read the article

  • ASP.NET MVC: shortcut for Response.Write and String.Format

    - by pcampbell
    I've found a pattern in my Views like this: <% if (someCondition) { Response.Write(string.Format("Hello {0}, Visitor {1} on {2}.", userName, someCounter, someDate)); } else { Response.Write(string.Format("Foo is {0}.", bar)); } %> The question here is around DRY and Response.Write(string.Format()). Are there better, or more concise ways to . Consider that HTML encoding would be a nice feature to include, perhaps as a boolean to a method call of some kind (extension method on Html?. Is there an obvious extension method that I'm missing? Do you have an extension method that you rely on to achieve this functionality?

    Read the article

  • C#: Multiline TextBox with TextBox.WordWrap Displaying Long Base64 String

    - by Peter Lee
    Hi, Happy New Year! I have a textbox to display a very long Base64 string. The TextBox.Multline = true and TextBox.WordWrap = true. The issue is caused by the auto-word-boundary detection of the TextBox itself. The Base64 string has '+' as one of the 64 characters for Base64 encoding. Therefore, the TextBox will wrap it up at the '+' character, which is not what I want (because the use might think there is a newline character around the '+' character). I just want my Base64 string displayed in Mulitline-mode in TextBox, but no word boundary detection, that is, if the TextBox.Width can only contain 80 characters, then each line should have exact 80 characters except the last line. I'm not sure if I made myself clear. Thanks. Peter

    Read the article

  • problem with editing fbjs string on the fly (fb_protected=true)

    - by Ahsan
    Hi there, I am facing this problem : I have a fbjs string which I use forDialog().showChoice() I populate part of the fbjs string from data I get through mysql. Now I update the data in fb:dialog and want this update to be reflected the next time I update/call the dialog box. However, seemingly, my fbjs string is wrap protected : <span class="fb_protected_wrapper" fb_protected="true"></span> Is there a way out ? Can anyone please help? Thanks. - ahsan

    Read the article

  • Doxygen C++ comment string parser in python?

    - by Sebastian
    Does anybody know of a python module to parse a doxygen style C++ comment string? I mean a string like this (simple example): /** * A constructor. * A more elaborate description of the constructor. * @param param1 test1 * @param param2 test2 */ and I would like to extract the brief, the long description, the parameters, the return value etc. I'm currently doing this using string methods and regular expressions but my solution is not very robust. Alternatively does anybody know an easy to use parser lib that I can set up quickly? Thanks in advance

    Read the article

  • djb2 Hash Function

    - by Jainish
    I am using the djb2 algorithm to generate the hash key for a string which is as follows hash(unsigned char *str) { unsigned long hash = 5381; int c; while (c = *str++) hash = ((hash << 5) + hash) + c; /* hash * 33 + c */ return hash; } Now with every loop there is a multiplication with two big numbers, After some time with the 4th of 5th character of the string there is a overflow as the hash value becomes huge What is the correct way to refactor so that the hash value does not overflow and the hashing also happens correctly

    Read the article

  • Regex - find and replace complete string occurrences only (not partial matches)

    - by vittore
    I'm not very good at regex but maybe there's a simple way to achieve this task. I'm given a string like "bla @a bla @a1 bla" I'm also given pairs like {"a", "a2"} , {"a1", "a13"}, and I need to replace @a with @a2 for the first pair, and @a1 with @a13 for the second one. The problem is when i use String.Replace and look for @a, it also replaces @a1 but it should not. I need it to completely match @a and avoid partially matching it in other places. Note: the given string could also be brackets, commas, dots and so on. However, pairs will always be [a-z]*[0-9]+ Help me with regex replace, please. Cheers

    Read the article

< Previous Page | 124 125 126 127 128 129 130 131 132 133 134 135  | Next Page >