473,388 Members | 1,423 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,388 software developers and data experts.

Equivalent of Fixed

I was using .Net Reflector to look at some methods in the String class
and found this one:

Friend Sub AppendInPlace(ByVal value As Char*, ByVal count As Integer,
ByVal currentLength As Integer)
Dim local1 As Char*
Fixed local1 = AddressOf Me.m_firstChar
Dim num1 As Integer
For num1 = 0 To count - 1
local1((currentLength + num1)) = value(num1)
Next num1
End Fixed
Me.SetLength((currentLength + count))
Me.NullTerminate
End Sub

In C# is shows like this:

internal unsafe void AppendInPlace(char* value, int count, int
currentLength)
{
fixed (char* local1 = &this.m_firstChar)
{
for (int num1 = 0; num1 < count; num1++)
{
local1[currentLength + num1] = value[num1];
}
}
this.SetLength(currentLength + count);
this.NullTerminate();
}
fixed is apparently a statement in C# but I was curious about its use
in VB.Net. Specifically the Fixed .. End Fixed construct. This is
obviously invalid as it wont even compile in the IDE. So why is
Reflector showing its output? How would the C# code be translated to
VB.Net?

Nov 21 '05 #1
3 2729
Chris,

"Chris Dunaway" <du******@gmail.com> schrieb:
I was using .Net Reflector to look at some methods in the String class
and found this one:

Friend Sub AppendInPlace(ByVal value As Char*, ByVal count As Integer,
ByVal currentLength As Integer)
Dim local1 As Char*
Fixed local1 = AddressOf Me.m_firstChar
Dim num1 As Integer
For num1 = 0 To count - 1
local1((currentLength + num1)) = value(num1)
Next num1
End Fixed
Me.SetLength((currentLength + count))
Me.NullTerminate
End Sub

In C# is shows like this:

internal unsafe void AppendInPlace(char* value, int count, int
currentLength)
{
fixed (char* local1 = &this.m_firstChar)
{
for (int num1 = 0; num1 < count; num1++)
{
local1[currentLength + num1] = value[num1];
}
}
this.SetLength(currentLength + count);
this.NullTerminate();
}
fixed is apparently a statement in C# but I was curious about its use
in VB.Net. Specifically the Fixed .. End Fixed construct. This is
obviously invalid as it wont even compile in the IDE. So why is
Reflector showing its output? How would the C# code be translated to
VB.Net?


Something similar to 'fixed' can be archieved using
'System.Runtime.InteropServices.GCHandle.Alloc' and
'System.Runtime.InteropServices.GCHandle.AddressOf PinnedObject'. However,
as VB.NET doesn't support pointers the way C# does, a direct equivalent to
the C# code for VB.NET doesn't exist.

--
M S Herfried K. Wagner
M V P <URL:http://dotnet.mvps.org/>
V B <URL:http://classicvb.org/petition/>

Nov 21 '05 #2
I thought so. I was just curious as to why Reflector was outputting it
that way.

Nov 21 '05 #3
"Chris Dunaway" <du******@gmail.com> schrieb:
I thought so. I was just curious as to why Reflector was outputting it
that way.


Mhm... I think it's better that Reflector outputs this code instead of
saying "No VB.NET version available" ;-).

--
M S Herfried K. Wagner
M V P <URL:http://dotnet.mvps.org/>
V B <URL:http://classicvb.org/petition/>

Nov 21 '05 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

7
by: jelle | last post by:
I now some hostility to functional programming is flaming up now and then; still could someone suggest me a pythonic equivalent for Mathematica's FixedPoint function? For those not familiar with...
1
by: Koen | last post by:
Hi, could anyone please tell me how I can get the equivalent of this: fprintf(aFile,"-20.15g",aDouble); but in C++ using formatted streams? I tried with C++ formatted streams using:...
12
by: Michael | last post by:
How would I go about shrinking the buffer that was allocated with new, or expanding it in place? I basically need a realloc equivalent for new. Thanks in advance. Michael
24
by: hjbortol | last post by:
Hi! Is the expression "a >= b" equivalent to "a - b >= 0" in C/C++? Is this equivalence an IEEE/ANSI rule? Or is this machine/compiler dependent? Any references are welcome! Thanks in...
14
by: hilz | last post by:
Hi all, What is the equivalent of VARCHAR2 in access? thanks hilz
0
by: Matt | last post by:
I am currently converting a Java application to C# and have found that a couple of modules use a MimeMessage Class to decompose MIME messages received via HTTP. Does anyone know of an equivalent...
3
by: VMI | last post by:
Is there an Application.StartupPath equivalent for web? I want to open a txt file myFile.txt and it will always be on the same dir the aspx will be, but I don't want to give it a fixed path. ...
14
by: grid | last post by:
Hi, I have a certain situation where a particular piece of code works on a particular compiler but fails on another proprietary compiler.It seems to have been fixed but I just want to confirm if...
18
by: Csaba Gabor | last post by:
Is there a straightforward way of implementing a PHP equivalent to window.setTimeout? In a javascript web app, it's often the case that things are done on an event driven basis. For example,...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.