473,699 Members | 2,279 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Implicit conversion of an array

Given:
Class Data
{
Public Data (string[] vals) { /*Fills properties*/ }
}

public Data[] ParseFile (StreamReader input)
{
ArrayList list = new ArrayList();
string line = input.ReadLine( );
while (line!=null)
{
list.Add (new Data (line.Split ('|')));
}

Is there a way to declare an implicit conversion such that

return list.ToArray();

Works?

}

TIA,
Dave
Feb 7 '06 #1
1 1273

"Dave" <Da**@discussio ns.microsoft.co m> wrote in message
news:54******** *************** ***********@mic rosoft.com...
Given:
Class Data
{
Public Data (string[] vals) { /*Fills properties*/ }
}

public Data[] ParseFile (StreamReader input)
{
ArrayList list = new ArrayList();
string line = input.ReadLine( );
while (line!=null)
{
list.Add (new Data (line.Split ('|')));
}

Is there a way to declare an implicit conversion such that

return list.ToArray();

Works?


Don't think so. Why not just cast?
Feb 8 '06 #2

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

Similar topics

1
1857
by: Christophe Poucet | last post by:
Hellom I have an issue with implicit conversions. Apparently when one calls an operator on a class Y which has a conversion operator to class X which has the operator . Sadly it will not do implicit conversion for this case, however if instead of class X we just use a pointer then the implicit conversion will work. Anyone have any ideas why it will not do implicit conversion?
3
2073
by: Siemel Naran | last post by:
Here is a question about implicit conversion from T (&) to ptrcarray<T>. I wrote a class template <class T> struct ptrcarray { T * array; size_t size;
8
2592
by: Roger Leigh | last post by:
-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 A lot of functions use const pointer arguments. If I have a non-const pointer, it is transparently made const when I pass it to the function, e.g. char * -> const char *. However, this does not appear to work when I add another level of indirection: void test1 (char **value) {}
11
7610
by: Steve Gough | last post by:
Could anyone please help me to understand what is happening here? The commented line produces an error, which is what I expected given that there is no conversion defined from type double to type Test. I expected the same error from the following line, but it compiles fine. The double is silently truncated to an int and then fed in to the implicit conversion operator. Why does this happen? Is there any way that I can keep the implicit...
11
12774
by: Aaron Queenan | last post by:
Given the classes: class Class { public static implicit operator int(Class c) { return 0; } } class Holder
36
3626
by: Chad Z. Hower aka Kudzu | last post by:
I have an implicit conversion set up in an assembly from a Stream to something else. In C#, it works. In VB it does not. Does VB support implicit conversions? And if so any idea why it would work in a C# program but not VB? -- Chad Z. Hower (a.k.a. Kudzu) - http://www.hower.org/Kudzu/ "Programming is an art form that fights back"
4
8561
by: Petro | last post by:
Good morning The following code generates the exception: "Option Strict On disallows implicit conversion from System.Array to 1-dimensional array of 'String'. I've been unable to find the conversion command that works. If any of you fine folks could point me in the right direction it would be appreciated ------------------------------------ Dim rdr As SqlDataReader = cmd.ExecuteReade Dim roleList As New ArrayLis
1
1554
thav
by: thav | last post by:
I'm taking an intro class right now , I'm not having any fun so far. I keep getting implicit conversion. I tried everything from .toString and declaring the array as a string which gives me problems later down when using a foreach statement later on. Can anyone point me in the right direction? I created an Array. Contact Contacts = new Contact; and I am getting string input from users, using the Console.ReadLine. Then I created an...
19
3897
by: =?iso-8859-1?b?VG9t4XMg0yBoyWlsaWRoZQ==?= | last post by:
Coming originally from C++, I used to do the likes of the following, using a pointer in a conditional: void Func(int *p) { if (p) { *p++ = 7; *p++ = 8;
8
5663
by: jonpb | last post by:
Hi, Is it possible to define a implicit operator from base to derived types in C#? I have a Point class and would like to derive a Vector class from it and add a couple new vector related functions, like Normalize(). The problem is Vector cannot use any of the Point operator overloads with a compile time error that there is no implicit conversion from Point to Vector. I tried adding an implicit operator to Vector: public static implicit...
0
8623
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
9048
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
8931
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
7767
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
5878
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4635
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
3064
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
2359
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2014
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.