c# - What is the difference between IRandomAccessStream and RandomAccessStream? -
i have used following code save taken image:
private async void button_click_2(object sender, routedeventargs e) { storagefile photo = await windows.storage.knownfolders.pictureslibrary.getfileasync("image.jpg"); bitmapimage bmp = new bitmapimage(); using (irandomaccessstream stream = await photo.openasync(fileaccessmode.read)) { bmp.setsource(stream); } img.source = bmp; } what use of irandomaccessstream , difference on replacing randomaccessstream?
it's confusing because have similar names. related not in way 1 assume.
randomaccessstream static helper class.
irandomaccessstream interface concreete random access streams implement, such filerandomaccessstream , inmemoryrandomaccessstream.
this means not interchangeable. use randomaccessstream perform operations, namely copying data between 2 instances of other streams.
photo.openasync return filerandomaccessstream unless need specific functionality concrete class provides, should stick programming against interface, irandomaccessstream.
Comments
Post a Comment