473,396 Members | 1,966 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,396 software developers and data experts.

Custom Nullable Class

I developed a custom file attachments class for an application and from the
UI the user can choose to upload attachments. There is a add method that
takes a FileAttachmentCollection object, runs a for each, and uploads each
attachment. I was thinking that it would be nice to allow it to be Nullable
if they happen not choose to upload attachments when submitting data. When I
try Public Sub Add(attachments As Nullable(Of FileAttachmentCollection) I
get: Type argument 'BusinessLogicLayer.FileAttachmentCollection' does not
satisfy the 'Structure' constraint for type parameter 'T'. I am doing the
following for my collection.

Public Class FileAttachmentCollection
Inherits System.Collections.ObjectModel.Collection(Of FileAttachment)
End Class

Any thoughts on how to correct this error?
Is there an easy way to fix this?
Jun 28 '06 #1
1 2020
Nick,
Any thoughts on how to correct this error?
Is there an easy way to fix this?


Yes, just change the signature to

Public Sub Add(attachments As FileAttachmentCollection)

Since FileAttachmentCollection is a Class, it's already nullable.
Mattias

--
Mattias Sjögren [C# MVP] mattias @ mvps.org
http://www.msjogren.net/dotnet/ | http://www.dotnetinterop.com
Please reply only to the newsgroup.
Jun 28 '06 #2

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

Similar topics

9
by: Mark Rae | last post by:
Hi, I posted a couple of days ago about the possibility of "simulating" in ..NET1.1 the nullable datatypes available in .NET2.0 - I'm nearly there, but require a bit more guidance. Basically,...
6
by: Steven Livingstone | last post by:
Bit of advice here folks. I am creating a default constructor that just initializes a new instance of my object and a secon constructor that takes an ID and loads an object with data from the...
1
by: Joe Bloggs | last post by:
Hi, Can someone please kindly show me how to determine if a type (read value type) is Nullable. MSDN has this KB: How to: Identify a Nullable Type (C# Programming Guide)...
8
by: Sam Kong | last post by:
Hello, I want to define a generic class which should accept only nullable types or reference types. What's the best way to costrain it? --------- class MyClass<T>{ ...
5
by: =?Utf-8?B?emlubw==?= | last post by:
in .net 2.0, the class (myClass) contains a property defined as: private _creationDate as As Nullable(Of DateTime) Public Property CreationDate() As Nullable(Of DateTime) Get If...
2
by: Rick | last post by:
I have a business object (class) with some nullable properties declared like this: Private _MyProp as Nullable(of Int16) public Property MyProp as Nullable(Of Int16) get Return _MyProp end...
3
by: Tony Johansson | last post by:
Hello! Is it possible to declare existing .net generics to have nullable types(for example type int? ) ? If the answer on the previous question is yes then I assume that you can also define...
8
by: Tony Johansson | last post by:
Hello! Jon skeet answer this question in a previous mail for several days ago if nullable type is a reference or a value type? With the following answer. It's a struct - otherwise there'd be...
1
by: prog123 | last post by:
Hi! If I have a Nullable type variable, I can set its initial value using a quotation mark like this: aNullableVariableOfInteger = 4 In the background an instance of the type Nullable(Of...
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:
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...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
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
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
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
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
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,...

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.