|
The confusion comes from the fact that the string is immutable. When you change the value of s2, it's actually a whole new string object that is created. If it had changed the contents of the memory that s2 was pointing to, it would have changed s1 too.
DaveBTW, in software, hope and pray is not a viable strategy. (Luc Pattyn)Visual Basic is not used by normal people so we're not covering it here. (Uncyclopedia)
|
|
|
|
|
Thank you! It's getting clearer 
|
|
|
|
|
No problem
We've all been there at some point on this one!
There are reasons why the string class is like this - a reference type that behaves like a value type. Research it if you're interested, but it's down to the fact that a string isn't really a string, it's a null terminated char array - i.e. each character is stored in ajacent memory locations with a null character at the end to dertermine where the string finishes.
It is possible to create a mutable string by using 'unsafe', 'fixed' and pointers to manipulte the contents of the array in memory but it's not advised.
DaveBTW, in software, hope and pray is not a viable strategy. (Luc Pattyn)Visual Basic is not used by normal people so we're not covering it here. (Uncyclopedia)
|
|
|
|
|
Hi Dave,
DaveyM69 wrote: a string ... is a null terminated char array - i.e. each character is stored in ajacent memory locations with a null character at the end to dertermine where the string finishes
Not so. That is true for C/C++ but not Java/C#.
How else would this snippet output "len=2":
char c='\0';
string s="";
s=s+c;
s=s+c;
log("len="+s.Length);
I don't think we are supposed to even know *how* strings get stored, it suffices to know strings are collections of characters and there aren't any special characters, so NULL is handled like everything else.
The good thing is string.Length seems to be an O(1) operation. So it suggests a length+content implementation, as was used in Pascal.
Luc Pattyn [Forum Guidelines] [My Articles]
- before you ask a question here, search CodeProject, then Google
- the quality and detail of your question reflects on the effectiveness of the help you are likely to get
- use the code block button (PRE tags) to preserve formatting when showing multi-line code snippets
|
|
|
|
|
Interesting. I never thought to look it up.
This page[^] has some stuff on it, and the Memory Usage secions has some more details specific to this.
Thanks for the correction - learned something new today
DaveBTW, in software, hope and pray is not a viable strategy. (Luc Pattyn)Visual Basic is not used by normal people so we're not covering it here. (Uncyclopedia)
|
|
|
|
|
Hi,
can anyone suggest me some idea about "vehicle tracking using sensor network"....
can this can be implemented in c#
|
|
|
|
|
R.Krishnakumar wrote: can anyone suggest me some idea about "vehicle tracking using sensor network"....
Get a GPS-tracker (cheap), use it to find out where you are, use some map-api to draw that (Microsoft has maps, Google has maps, Yahoo does maps)
R.Krishnakumar wrote: can this can be implemented in c#
Yes.
I are troll
|
|
|
|
|
its possible to bring google earth map on to my application
|
|
|
|
|
Was that a question or a statement? Either way, this is a big task - are you really sure you're up to doing this. I ask this because my company specialises in doing this type of work, and it's not a trivial undertaking. You need some form of transponder in the vehicle to update you with the position in real time. Companies can end up paying hundreds of thousands (sometimes even millions) for reliable solutions to this problem.
"WPF has many lovers. It's a veritable porn star!" - Josh Smith As Braveheart once said, "You can take our freedom but you'll never take our Hobnobs!" - Martin Hughes.
My blog | My articles | MoXAML PowerToys
|
|
|
|
|
google earth map is online. you can use it, if you have an internet connection.
try to search it in google for "google maps api".
It is only javascript code.
|
|
|
|
|
Yeah, but you can only use the free version if the service you base on the maps is publicly available. For internal use/behind a firewall/anything company, you'll need to register for the Enterprise version of Maps
I are troll
|
|
|
|
|
|
Tie a long string to the car, and tie the other end of the string to your computer. When the string breaks, you know that the car has traveled beyond your coverage zone.
"Why don't you tie a kerosene-soaked rag around your ankles so the ants won't climb up and eat your candy ass..." - Dale Earnhardt, 1997 ----- "...the staggering layers of obscenity in your statement make it a work of art on so many levels." - Jason Jystad, 10/26/2001
|
|
|
|
|
Hi,
I'm trying to run another app from my C# code, under the context of another user. I've been round the web and got the following code from MSDN:
ProcessStartInfo psi = new ProcessStartInfo(@"C:\Windows\Explorer.exe");
psi.UseShellExecute = false;
psi.Domain = userParts[0];
psi.UserName = userParts[1];
psi.Password = password;
Process.Start(psi);
Which i believe is fine - username and pwd are set correctly and are for a user that i can use to login to our domain. However, i keep getting an error that i have 'unknown username or bad password' - I am connecting from home at the minute over our VPN connection, and i'm wondering if that maybe has something to do with it...
Wondering if anybody has seen something similar?
|
|
|
|
|
Hi, I'm currently in my final year and i'm developing a sofware for my final year project. The basic operation of the software is to track the time of pressence and absence of a student infront of his/ her work station. The programming language would be C# and i would be using a SDK "VERILOOK" from neurotechnology.com.
What i need to know which libraries are needed from the following:
1.Neurotec Library
2.Neurotec.Cameras.CameraMan Library
3.Neurotec.Biometrics.Gui Library
4.Neurotec.Biometrics.NLExtractor Library
5.Neurotec.Biometrics.NMatcher Library
6.Neurotec.Biometrics.NTemplate Library
7.Neurotec.Biometrics.Images Library
8.Neurotec.Licensing Library
There are the trial files available for download at the website and definations and explainations including the documentation will be included. Would really appreciate if i could also have the developed source code at diploma level for reference. Thanks.
|
|
|
|
|
You aren't going to get source code. However, you will most definitely require Neurotec.Cameras.CameraMan, and possibly NLExtractor, NMatcher and NTemplate.
You probably wouldn't actually require such complex libraries. If they aren't a requirement of the course, maybe you could look at the source code for some of the matching libraries here (note that I said 'look at' and not 'copy')
|
|
|
|
|
RogerLum wrote: I'm currently in my final year and i'm developing a sofware for my final year project.
Well, that's a good start. YOU'RE developing the software.
RogerLum wrote: Would really appreciate if i could also have the developed source code
Oh wait, I was wrong. I thought you said you were developing it?
Tell you what. I'll just get in touch with somebody at Microsoft and tell them I'm developing an Operating System, if only they'll give me the source code to Windows 7 to act as a reference.
"WPF has many lovers. It's a veritable porn star!" - Josh Smith As Braveheart once said, "You can take our freedom but you'll never take our Hobnobs!" - Martin Hughes.
My blog | My articles | MoXAML PowerToys
|
|
|
|
|
Dear All
I've been trying to code a code that record the users' voice from the mic but I seem to get stuck in some portion in which it keep showing me the error that the Microsoft.visualbasic.devices is missing? any help
here is my code incase the problem is on my code
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using Microsoft.VisualBasic.Devices;
using Microsoft.VisualBasic;
using System.Runtime.InteropServices;
namespace WindowsApplication1
{
public partial class Form1 : Form
{
[DllImport("winmm.dll", EntryPoint = "mciSendStringA", CharSet = CharSet.Ansi, SetLastError = true, ExactSpelling = true)]
private static extern int mciSendString(string lpstrCommand, string lpstrReturnString, int uReturnLength, int hwndCallback);
public Form1()
{
InitializeComponent();
}
private void Form1_Load(object sender, EventArgs e)
{
}
private void Record_Click(object sender, EventArgs e)
{
mciSendString("open new Type waveaudio Alias recsound", "", 0, 0);
mciSendString("record recsound", "", 0, 0);
}
private void SaveStop_Click(object sender, EventArgs e)
{
mciSendString("save recsound c:\\record.wav", "", 0, 0);
mciSendString("close recsound ", "", 0, 0);
Computer c = new Computer();
c.Audio.Stop();
}
private void Read_Click(object sender, EventArgs e)
{
Computer computer = new Computer();
computer.Audio.Play("c:\\record.wav", AudioPlayMode.Background);
}
}
}
|
|
|
|
|
Stop using the Computer class, and use the same instance of a SoundPlayer class instead
|
|
|
|
|
I'm not familiar with that class really; thankx for your help I appreciate it
|
|
|
|
|
The SoundPlayer class is new to the .net framework, version 2.0. It provides the StartAsync and Stop methods. Put it as a variable in the SaveStop_Click and the Read_Click voids, and instantiate it. Then, just call the methods. Overall, it would look like this:
private void SaveStop_Click(object sender, EventArgs e)
{
SoundPlayer player = new SoundPlayer();
player.Stop();
}
private void Read_Click(object sender, EventArgs e)
{
SoundPlayer player = new SoundPlayer(@"C:\record.wav");
player.PlayAsync();
}
|
|
|
|
|
Project-Add Reference-
in the .Net Option Find Micorsoft.VisualBasic and Add it to the Reference
you will find you can using the namespace now;
|
|
|
|
|
hi!!
Am developing smart device application using vs2008(.net compact framework 3.5)now my query is how to rollover the picures using c#.net ?am usig picturebox control...can anyone please help me...
Thanks in Advance...
|
|
|
|
|
mouseover
Never underestimate the power of human stupidity
RAH
|
|
|
|
|
I'm not certain whether the CF supports this, but you could use the MouseEnter and MouseLeave events
|
|
|
|