Hello All,
I have a 2-dimensional array that I am storing as a session variable. I have
no idea on how I can cast the session variable back to 2-dimensional array.
Any pointers?
Reference code below...
Array declaration:
DateTime[][] DateRangesForDa taLists = new DateTime[5][];
Sample element population:
DateRangesForDa taLists[0] = new DateTime[2];
DateRangesForDa taLists[0][0] = System.DateTime .Today;
DateRangesForDa taLists[0][1] = new
DateTime(System .DateTime.Today .Year,System.Da teTime.Today.Mo nth,1);
Storing in session:
Session["DataListStartE ndDates"] = DateRangesForDa taLists;
Trying to access from session:
private DateTime GetDateFromSess ion(int FirstIndex, int SecondIndex)
{
DateTime[,] DateRangesForDa taLists = new DateTime[5,2];
DateRangesForDa taLists = (DateTime[,])Session["DataListStartE ndDates"];
return DateRangesForDa taLists[FirstIndex,Seco ndIndex];
}
And in the above method it is giving me an error: "Specified cast is not
valid." What am I doing wrong?
Thanks for your help!! 5 3879
Try:
DateTime[][] DateRangesForDa taLists =
(DateTime[][])Session["DataListStartE ndDates"];
karl
--
MY ASP.Net tutorials http://www.openmymind.net/
"Diffident" <Di*******@disc ussions.microso ft.com> wrote in message
news:BA******** *************** ***********@mic rosoft.com... Hello All,
I have a 2-dimensional array that I am storing as a session variable. I have no idea on how I can cast the session variable back to 2-dimensional array. Any pointers?
Reference code below...
Array declaration: DateTime[][] DateRangesForDa taLists = new DateTime[5][];
Sample element population: DateRangesForDa taLists[0] = new DateTime[2]; DateRangesForDa taLists[0][0] = System.DateTime .Today; DateRangesForDa taLists[0][1] = new DateTime(System .DateTime.Today .Year,System.Da teTime.Today.Mo nth,1);
Storing in session: Session["DataListStartE ndDates"] = DateRangesForDa taLists;
Trying to access from session: private DateTime GetDateFromSess ion(int FirstIndex, int SecondIndex) { DateTime[,] DateRangesForDa taLists = new DateTime[5,2] DateRangesForDa taLists = (DateTime[,])Session["DataListStartE ndDates"]; return DateRangesForDa taLists[FirstIndex,Seco ndIndex]; }
And in the above method it is giving me an error: "Specified cast is not valid." What am I doing wrong?
Thanks for your help!!
Nope, it gives me the same error message.
When you observe my code, I declared the array as a jagged array but while
retrieving I am casting it to a normal 5x2 array.....is that the problem?
How can I cast it into a jagged array?
"Karl Seguin [MVP]" wrote: Try:
DateTime[][] DateRangesForDa taLists = (DateTime[][])Session["DataListStartE ndDates"];
karl
-- MY ASP.Net tutorials http://www.openmymind.net/
"Diffident" <Di*******@disc ussions.microso ft.com> wrote in message news:BA******** *************** ***********@mic rosoft.com... Hello All,
I have a 2-dimensional array that I am storing as a session variable. I have no idea on how I can cast the session variable back to 2-dimensional array. Any pointers?
Reference code below...
Array declaration: DateTime[][] DateRangesForDa taLists = new DateTime[5][];
Sample element population: DateRangesForDa taLists[0] = new DateTime[2]; DateRangesForDa taLists[0][0] = System.DateTime .Today; DateRangesForDa taLists[0][1] = new DateTime(System .DateTime.Today .Year,System.Da teTime.Today.Mo nth,1);
Storing in session: Session["DataListStartE ndDates"] = DateRangesForDa taLists;
Trying to access from session: private DateTime GetDateFromSess ion(int FirstIndex, int SecondIndex) { DateTime[,] DateRangesForDa taLists = new DateTime[5,2] DateRangesForDa taLists = (DateTime[,])Session["DataListStartE ndDates"]; return DateRangesForDa taLists[FirstIndex,Seco ndIndex]; }
And in the above method it is giving me an error: "Specified cast is not valid." What am I doing wrong?
Thanks for your help!!
"Diffident" <Di*******@disc ussions.microso ft.com> wrote in message
news:BA******** *************** ***********@mic rosoft.com... Hello All,
I have a 2-dimensional array that I am storing as a session variable. I have no idea on how I can cast the session variable back to 2-dimensional array. Any pointers?
Reference code below...
Array declaration: DateTime[][] DateRangesForDa taLists = new DateTime[5][];
Hmm, that isn't a 2-dimensional array...rather an array of arrays...though t
I'd point that out. A two dimensional array would be defined as DateTime[,]
DateRangesForDa taLists, would it not? I may be wrong, haven't dealth with
2-dimensional arrays in a long time in C#....in VB.Net, though, DateTime()()
is considered an array of arrays and DateTime(,) is 2-dimensional...
Check it out, remember, I am hardly ever correct in my assumptions... :)
Especially, this early in the morning...
Mythran
how is it declared? why can't you cast it as it is declared? post some code
if you still need help.
--
Regards,
Alvin Bruney [MVP ASP.NET]
[Shameless Author plug]
The Microsoft Office Web Components Black Book with .NET
Now Available @ www.lulu.com/owc
Forth-coming VSTO.NET - Wrox/Wiley 2006
-------------------------------------------------------
"Karl Seguin [MVP]" <karl REMOVE @ REMOVE openmymind REMOVEMETOO . ANDME
net> wrote in message news:#G******** ******@TK2MSFTN GP12.phx.gbl... Try:
DateTime[][] DateRangesForDa taLists = (DateTime[][])Session["DataListStartE ndDates"];
karl
-- MY ASP.Net tutorials http://www.openmymind.net/
"Diffident" <Di*******@disc ussions.microso ft.com> wrote in message news:BA******** *************** ***********@mic rosoft.com... Hello All,
I have a 2-dimensional array that I am storing as a session variable. I have no idea on how I can cast the session variable back to 2-dimensional array. Any pointers?
Reference code below...
Array declaration: DateTime[][] DateRangesForDa taLists = new DateTime[5][];
Sample element population: DateRangesForDa taLists[0] = new DateTime[2]; DateRangesForDa taLists[0][0] = System.DateTime .Today; DateRangesForDa taLists[0][1] = new DateTime(System .DateTime.Today .Year,System.Da teTime.Today.Mo nth,1);
Storing in session: Session["DataListStartE ndDates"] = DateRangesForDa taLists;
Trying to access from session: private DateTime GetDateFromSess ion(int FirstIndex, int SecondIndex) { DateTime[,] DateRangesForDa taLists = new DateTime[5,2] DateRangesForDa taLists = (DateTime[,])Session["DataListStartE ndDates"]; return DateRangesForDa taLists[FirstIndex,Seco ndIndex]; }
And in the above method it is giving me an error: "Specified cast is not valid." What am I doing wrong?
Thanks for your help!!
I'm not sure why my code doesn't work, this code compiles fine for me:
DateTime[][] DateRangesForDa taLists = new DateTime[2][];
DateRangesForDa taLists[0] = new DateTime[2];
DateRangesForDa taLists[0][0] = DateTime.Today;
DateRangesForDa taLists[0][1] = DateTime.Today. AddYears(1);
DateRangesForDa taLists[1] = new DateTime[3];
DateRangesForDa taLists[1][0] = DateTime.Today;
DateRangesForDa taLists[1][1] = DateTime.Today. AddYears(1);
DateRangesForDa taLists[1][2] = DateTime.Today. AddYears(2);
object o = DateRangesForDa taLists;
DateTime[][] back = (DateTime[][])o;
Karl
--
MY ASP.Net tutorials http://www.openmymind.net/
"Diffident" <Di*******@disc ussions.microso ft.com> wrote in message
news:DB******** *************** ***********@mic rosoft.com... Nope, it gives me the same error message.
When you observe my code, I declared the array as a jagged array but while retrieving I am casting it to a normal 5x2 array.....is that the problem?
How can I cast it into a jagged array?
"Karl Seguin [MVP]" wrote:
Try:
DateTime[][] DateRangesForDa taLists = (DateTime[][])Session["DataListStartE ndDates"];
karl
-- MY ASP.Net tutorials http://www.openmymind.net/
"Diffident" <Di*******@disc ussions.microso ft.com> wrote in message news:BA******** *************** ***********@mic rosoft.com... > Hello All, > > I have a 2-dimensional array that I am storing as a session variable. I > have > no idea on how I can cast the session variable back to 2-dimensional > array. > Any pointers? > > Reference code below... > > Array declaration: > DateTime[][] DateRangesForDa taLists = new DateTime[5][]; > > Sample element population: > DateRangesForDa taLists[0] = new DateTime[2]; > DateRangesForDa taLists[0][0] = System.DateTime .Today; > DateRangesForDa taLists[0][1] = new > DateTime(System .DateTime.Today .Year,System.Da teTime.Today.Mo nth,1); > > Storing in session: > Session["DataListStartE ndDates"] = DateRangesForDa taLists; > > Trying to access from session: > private DateTime GetDateFromSess ion(int FirstIndex, int SecondIndex) > { > DateTime[,] DateRangesForDa taLists = new DateTime[5,2] > DateRangesForDa taLists = (DateTime[,])Session["DataListStartE ndDates"]; > return DateRangesForDa taLists[FirstIndex,Seco ndIndex]; > } > > And in the above method it is giving me an error: "Specified cast is > not > valid." What am I doing wrong? > > > Thanks for your help!! > This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: Rajesh Abraham |
last post by:
I am new to Asp world and I have a doubt as follows. I
have a class called objTranslator, which I declare and
initiate global.asax as follows.
Session_Start
csTranslator.objTranslator sesObjTranslator= new
objTranslator();
Session=sesObjTranslator;
----------------
Now in WebForm
|
by: Kurt |
last post by:
Hi I was trying to get this VB type code to work in C
Sub SetColumns_Example(
Dim ol As Outlook.Applicatio
Dim MyFolder As MAPIFolde
Dim itms As Item
Dim itm As Objec
Dim dtmStart As Date, dtmEnd As Dat
Dim lngElapsed As Lon
Set ol = New Outlook.Applicatio
|
by: Remco |
last post by:
Hi,
Let me try to simply explain my questions.
I've created a portal site with different types of users, e.g. Portal
Administrators and Normal Users.
One base class SessionUser (has a enum field UserType) and for each type of
user a inherited class like SessionMasterUser and SessionNormalUser.
|
by: Razak |
last post by:
Hi,
I have a class which basically do Impersonation in my web application. From
MS KB sample:-
++++++++++++++++++++code starts
Dim impersonationContext As
System.Security.Principal.WindowsImpersonationContext
Dim currentWindowsIdentity As System.Security.Principal.WindowsIdentity
|
by: Carlo Marchesoni |
last post by:
I have an ASP.NET/C# solution, where I can perfectly cast something I stored
in the session object to a class of mine (BackEnd), as this:
->be = (BackEnd)Session;<-
But if I try to do the same:
->this.backend = (BackEnd)System.Web.HttpContext.Current.Session<--
in another project of the same solution I got:
public CustomerAccess(BackEnd backend, string culture) {
this.backend = (BackEnd)System.Web.HttpContext.Current.Session;
....
| |
by: Jeff |
last post by:
ASP.NET 2.0
In the business logic layer I've got the code (see CODE) below, this code
gives a compile error (see ERROR)
CODE:
List<Messagemessages = null;
messages = HttpContext.Current.Session;
ERROR:
|
by: Ronald Raygun |
last post by:
If I have the following class heirarchy:
class A{
protected $m_type;
function type(){return $this->m_type;}
}
class B extends A{}
class C extends B{}
|
by: Mark Rae [MVP] |
last post by:
"Lloyd Sheen" <a@b.cwrote in message
news:uL5TPXPvIHA.1688@TK2MSFTNGP06.phx.gbl...
Surely that will throw an exception because you're trying to populate a
DataSet variable with an object datatype...
--
Mark Rae
|
by: =?Utf-8?B?R2Vvc3Ns?= |
last post by:
Dear All,
I try to change a master page in the OnPreInit in a asp.net page.
(Session variable is guaranteed to have been assigned)
protected override void OnPreInit(EventArgs e){
if ((bool)session){
this.MasterPageFile = "~/NewMaster.master";
}
else{
this.MasterPageFile = "~/OrigianlMaster.master";
|
by: AndreH |
last post by:
Good day,
I have the a bit of an issue with retrieving an object from php's
session.
I set a session variable "user" from the class User as follows:
$user = new User();
// ... do some stuff to $user
$_SESSION = serialize($user);
|
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look !
Part I. Meaning of...
| |
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,...
|
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,...
|
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...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules.
He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms.
Adolph will...
|
by: TSSRALBI |
last post by:
Hello
I'm a network technician in training and I need your help.
I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs.
The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols.
I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
|
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
| |
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
|
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...
| |